diff --git a/runtime/src/runtime_api.rs b/runtime/src/runtime_api.rs index edf1c796..bc682849 100644 --- a/runtime/src/runtime_api.rs +++ b/runtime/src/runtime_api.rs @@ -1,6 +1,4 @@ -#[cfg(unix)] use std::collections::HashSet; - use log::info; use once_cell::sync::Lazy; use rocket::config::Shutdown; @@ -28,24 +26,8 @@ pub fn start_runtime_api() { let api_port = *API_SERVER_PORT; info!("Try to start the API server on 'http://localhost:{api_port}'..."); - // The shutdown configuration for the runtime API server: - let shutdown = Shutdown { - // We do not want to use the Ctrl+C signal to stop the server: - ctrlc: false, - - // Everything else is set to default for now: - ..Shutdown::default() - }; - - #[cfg(unix)] - { - // Now, shutdown needs to be mutable: - let mut shutdown = shutdown; - - // We do not want to use the termination signal to stop the server. - // This option, however, is only available on Unix systems: - shutdown.signals = HashSet::new(); - } + // Get the shutdown configuration: + let shutdown = create_shutdown(cfg!(windows)); // Configure the runtime API server: let figment = Figment::from(rocket::Config::release_default()) @@ -100,4 +82,20 @@ pub fn start_runtime_api() { .ignite().await.unwrap() .launch().await.unwrap(); }); +} + +fn create_shutdown(for_windows: bool) -> Shutdown { + let mut shutdown = Shutdown { + // We do not want to use the Ctrl+C signal to stop the server: + ctrlc: false, + + // Everything else is set to default for now: + ..Shutdown::default() + }; + + if for_windows { + shutdown.signals = HashSet::new(); + } + + shutdown } \ No newline at end of file