sd_notify fixes

This commit is contained in:
Robin Appelman 2025-11-01 00:24:04 +01:00
commit 3b7d53f693

View file

@ -30,7 +30,7 @@ async fn daemon_async(mut config: Config) -> Result<(), DaemonError> {
state.update(&config)?;
// now the namespaces are setup, we can tell systemd to start any service depending on them
notify(true, &[NotifyState::Ready]).map_err(DaemonError::Notify)?;
notify(false, &[NotifyState::Ready]).map_err(DaemonError::Notify)?;
let reload_signal = signal(SignalKind::hangup()).map_err(DaemonError::Signal)?;
let reload_signal = SignalStream::new(reload_signal).map(|_| Event::Reload);
@ -57,7 +57,7 @@ async fn daemon_async(mut config: Config) -> Result<(), DaemonError> {
match NotifyState::monotonic_usec_now() {
Ok(notify_time) => {
notify(true, &[NotifyState::Reloading, notify_time])
notify(false, &[NotifyState::Reloading, notify_time])
.map_err(DaemonError::Notify)?;
}
Err(error) => {
@ -75,7 +75,7 @@ async fn daemon_async(mut config: Config) -> Result<(), DaemonError> {
}
}
notify(true, &[NotifyState::Ready]).map_err(DaemonError::Notify)?;
notify(false, &[NotifyState::Ready]).map_err(DaemonError::Notify)?;
}
Event::Info => {
for namespace in &state.namespaces {
@ -95,6 +95,8 @@ async fn daemon_async(mut config: Config) -> Result<(), DaemonError> {
}
}
}
let _ = notify(false, &[NotifyState::Stopping]);
Ok(())
}