#![forbid(unsafe_code)]usecrate::server::Server;usecrate::shutdown::Shutdown;usecrate::signal_guard::SignalGuard;uselog::error;uselog::info;usestd::process::exit;usetokio::sync::broadcast;modserver;modservice;modshutdown;modsignal_guard;#[tokio::main]
async fnmain(){log4rs::init_file("log4rs.config.yml",Default::default()).unwrap();let version =env!("CARGO_PKG_VERSION");info!("MAIN: v{}", version);info!("MAIN: START");let(shutdown_tx, shutdown_rx)=broadcast::channel(256);let run =tokio::spawn(async move{let control =Shutdown::new(shutdown_rx);letmut server =Server::new(control);
server.run().await;});info!("MAIN: PARKED");SignalGuard::wait_for_stop(&shutdown_tx).await;info!("MAIN: STOP SIGNAL RECEIVED FROM OS");info!("MAIN: SEND STOP CONTROL SIGNAL TO SERVER");info!("MAIN: WAITING FOR EXIT");let run_result = run.await;match run_result {Ok(_)=>{info!("MAIN: EXIT SUCCESS");exit(exitcode::OK);}Err(server_fault)=>{error!("MAIN: EXIT FAILURE = {}", server_fault);exit(exitcode::SOFTWARE);}}}