diff --git a/Cargo.toml b/Cargo.toml index 01f6b78..5568270 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,3 +69,6 @@ napi-build = "2" [profile.release] lto = true strip = "symbols" + +[target.'cfg(unix)'.dependencies] +sd-notify = "0.5.0" diff --git a/src/server/mod.rs b/src/server/mod.rs index 5d64e82..bcfefef 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -177,7 +177,18 @@ impl Server { let rt = tokio::runtime::Runtime::new().unwrap(); rt.block_on(async move { let tcp_listener = TcpListener::bind(&addr).await.unwrap(); - log::debug!("Server listening on {}", addr); + let server_status_message = format!("Server listening on {}", addr); + log::debug!("{server_status_message}"); + + #[cfg(unix)] + { + use sd_notify::{NotifyState, notify}; + if let Err(e) = notify(&[NotifyState::Ready]) { + log::error!("Failed to notify systemd: {}", e); + } + + let _ = notify(&[NotifyState::Status(&server_status_message)]); + } match acme_config_meta { Some(acme) => {