Abstract over sd_notify

This commit is contained in:
Lambda 2024-09-26 16:27:58 -07:00 committed by Charles Hall
parent 6ab87f97dd
commit 39880cc6ac
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
2 changed files with 30 additions and 9 deletions

View file

@ -42,12 +42,12 @@ use crate::{
},
config::{self, Config, ListenComponent, ListenTransport},
database::KeyValueDatabase,
error, observability, services,
error, observability, services, set_application_state,
utils::{
self,
error::{Error, Result},
},
Services,
ApplicationState, Services,
};
pub(crate) async fn run(args: ServeArgs) -> Result<(), error::ServeCommand> {
@ -226,9 +226,7 @@ async fn run_server() -> Result<(), error::Serve> {
}
}
#[cfg(feature = "systemd")]
sd_notify::notify(true, &[sd_notify::NotifyState::Ready])
.expect("should be able to notify systemd");
set_application_state(ApplicationState::Ready);
tokio::spawn(shutdown_signal(handles));
@ -573,9 +571,7 @@ async fn shutdown_signal(handles: Vec<ServerHandle>) {
handle.graceful_shutdown(Some(Duration::from_secs(30)));
}
#[cfg(feature = "systemd")]
sd_notify::notify(true, &[sd_notify::NotifyState::Stopping])
.expect("should be able to notify systemd");
set_application_state(ApplicationState::Stopping);
}
async fn federation_disabled(_: Uri) -> impl IntoResponse {