From dc140f167570ae287347fd2461f813271226b4dc Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Sat, 6 Jan 2024 00:33:08 +0100 Subject: [PATCH] server: exit with non-zero code when running into errors starting --- server/src/main.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index c9e07f8..7a8cdb1 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -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(())