diff --git a/Cargo.lock b/Cargo.lock index fe1478b..72479cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -692,7 +692,7 @@ dependencies = [ [[package]] name = "git-fs" -version = "0.1.1-alpha.1" +version = "0.1.2-alpha.1" dependencies = [ "async-trait", "base64", diff --git a/src/daemon.rs b/src/daemon.rs index e56e708..41403e6 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -201,13 +201,10 @@ pub async fn run( Ok(()) } -pub fn spawn(config: app_config::Config) { +pub fn spawn(config: app_config::Config) -> Result<(), std::io::Error> { let runtime = tokio::runtime::Builder::new_multi_thread() .enable_all() .build() .unwrap_or_else(|e| panic!("Failed to create Tokio runtime: {e}")); - if let Err(e) = runtime.block_on(run(config, runtime.handle().clone())) { - error!("Daemon failed: {e}"); - panic!("Daemon failed: {e}"); - } + runtime.block_on(run(config, runtime.handle().clone())) } diff --git a/src/main.rs b/src/main.rs index e2321c0..794f7d6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -103,14 +103,18 @@ fn main() { match daemonize.start() { Ok(()) => { trc_handle.reconfigure_for_daemon(); - daemon::spawn(config); + if let Err(e) = daemon::spawn(config) { + error!("Daemon failed: {e}"); + std::process::exit(1); + } } Err(e) => { error!("Failed to spawn the daemon: {e}"); } } - } else { - daemon::spawn(config); + } else if let Err(e) = daemon::spawn(config) { + error!("Daemon failed: {e}"); + std::process::exit(1); } } Command::Reload => {}