server: exit with non-zero code when running into errors starting

This commit is contained in:
Valentin Tolmer 2024-01-06 00:33:08 +01:00 committed by nitnelave
parent f74f88f0c0
commit dc140f1675
1 changed files with 7 additions and 3 deletions

View File

@ -179,9 +179,13 @@ fn run_server_command(opts: RunOpts) -> Result<()> {
let config = infra::configuration::init(opts)?;
infra::logging::init(&config)?;
actix::run(
run_server(config).unwrap_or_else(|e| error!("Could not bring up the servers: {:#}", e)),
)?;
use std::sync::{Arc, Mutex};
let result = Arc::new(Mutex::new(Ok(())));
let result_async = Arc::clone(&result);
actix::run(run_server(config).unwrap_or_else(move |e| *result_async.lock().unwrap() = Err(e)))?;
if let Err(e) = result.lock().unwrap().as_ref() {
anyhow::bail!(format!("Could not set up servers: {:#}", e));
}
info!("End.");
Ok(())