From 9fe0ec08bf9e24286e780e58bab0f28623faf1ba Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 27 Dec 2025 19:20:08 +0100 Subject: [PATCH] Include sd-notify only on unix --- rs/hang-cli/Cargo.toml | 4 +++- rs/hang-cli/src/client.rs | 1 + rs/hang-cli/src/server.rs | 1 + rs/moq-relay/Cargo.toml | 4 +++- rs/moq-relay/src/main.rs | 1 + 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/rs/hang-cli/Cargo.toml b/rs/hang-cli/Cargo.toml index 4866cc697..f32a2fa93 100644 --- a/rs/hang-cli/Cargo.toml +++ b/rs/hang-cli/Cargo.toml @@ -24,8 +24,10 @@ clap = { version = "4", features = ["derive"] } hang = { workspace = true } hyper-serve = { version = "0.6", features = ["tls-rustls"] } moq-native = { workspace = true } -sd-notify = "0.4" tokio = { workspace = true, features = ["full"] } tower-http = { version = "0.6", features = ["cors", "fs"] } tracing = "0.1" url = "2" + +[target.'cfg(unix)'.dependencies] +sd-notify = "0.4" diff --git a/rs/hang-cli/src/client.rs b/rs/hang-cli/src/client.rs index e9af631a0..ac8de46b2 100644 --- a/rs/hang-cli/src/client.rs +++ b/rs/hang-cli/src/client.rs @@ -16,6 +16,7 @@ pub async fn client(config: moq_native::ClientConfig, url: Url, name: String, pu // Establish the connection, not providing a subscriber. let session = moq_lite::Session::connect(session, origin.consumer, None).await?; + #[cfg(unix)] // Notify systemd that we're ready. let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Ready]); diff --git a/rs/hang-cli/src/server.rs b/rs/hang-cli/src/server.rs index a1e491100..d0151afd6 100644 --- a/rs/hang-cli/src/server.rs +++ b/rs/hang-cli/src/server.rs @@ -27,6 +27,7 @@ pub async fn server( let server = config.init()?; + #[cfg(unix)] // Notify systemd that we're ready. let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Ready]); diff --git a/rs/moq-relay/Cargo.toml b/rs/moq-relay/Cargo.toml index b36129796..6b3e693bf 100644 --- a/rs/moq-relay/Cargo.toml +++ b/rs/moq-relay/Cargo.toml @@ -30,7 +30,6 @@ hyper-util = "=0.1.17" moq-lite = { workspace = true, features = ["serde"] } moq-native = { workspace = true } moq-token = { workspace = true } -sd-notify = "0.4" serde = { version = "1", features = ["derive"] } serde_with = { version = "3", features = ["json", "base64"] } thiserror = "2" @@ -41,5 +40,8 @@ tracing = "0.1" url = { version = "2", features = ["serde"] } web-transport-ws = { workspace = true } +[target.'cfg(unix)'.dependencies] +sd-notify = "0.4" + [dev-dependencies] tempfile = "3" diff --git a/rs/moq-relay/src/main.rs b/rs/moq-relay/src/main.rs index 83678e460..c0765aadf 100644 --- a/rs/moq-relay/src/main.rs +++ b/rs/moq-relay/src/main.rs @@ -40,6 +40,7 @@ async fn main() -> anyhow::Result<()> { tracing::info!(%addr, "listening"); + #[cfg(unix)] // Notify systemd that we're ready after all initialization is complete let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Ready]);