1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2024-12-27 11:04:35 +01:00

feat(systemd): call sd-notify after init and before exit

This commit is contained in:
Vladan Popovic 2022-11-25 21:23:21 +01:00
parent 66ad114e19
commit 06d3efc4d0

View file

@ -186,10 +186,20 @@ async fn run_server() -> io::Result<()> {
match &config.tls {
Some(tls) => {
let conf = RustlsConfig::from_pem_file(&tls.certs, &tls.key).await?;
bind_rustls(addr, conf).handle(handle).serve(app).await?;
let server = bind_rustls(addr, conf).handle(handle).serve(app);
#[cfg(feature = "systemd")]
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Ready]);
server.await?
}
None => {
bind(addr).handle(handle).serve(app).await?;
let server = bind(addr).handle(handle).serve(app);
#[cfg(feature = "systemd")]
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Ready]);
server.await?
}
}
@ -197,6 +207,9 @@ async fn run_server() -> io::Result<()> {
info!(target: "shutdown-sync", "Received shutdown notification, notifying sync helpers...");
services().globals.rotate.fire();
#[cfg(feature = "systemd")]
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Stopping]);
Ok(())
}