mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-12-28 03:34:16 +01:00
feat(systemd): call sd-notify after init and before exit
This commit is contained in:
parent
66ad114e19
commit
06d3efc4d0
1 changed files with 15 additions and 2 deletions
17
src/main.rs
17
src/main.rs
|
@ -186,10 +186,20 @@ async fn run_server() -> io::Result<()> {
|
||||||
match &config.tls {
|
match &config.tls {
|
||||||
Some(tls) => {
|
Some(tls) => {
|
||||||
let conf = RustlsConfig::from_pem_file(&tls.certs, &tls.key).await?;
|
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 => {
|
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...");
|
info!(target: "shutdown-sync", "Received shutdown notification, notifying sync helpers...");
|
||||||
services().globals.rotate.fire();
|
services().globals.rotate.fire();
|
||||||
|
|
||||||
|
#[cfg(feature = "systemd")]
|
||||||
|
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Stopping]);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue