mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-01-18 20:20:09 +00:00
Merge branch 'sd-notify' into 'next'
call sd-notify after init and before exit See merge request famedly/conduit!426
This commit is contained in:
commit
f4dd051a1d
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -404,6 +404,7 @@ dependencies = [
|
|||||||
"ruma",
|
"ruma",
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
"rust-argon2",
|
"rust-argon2",
|
||||||
|
"sd-notify",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
@ -2315,6 +2316,12 @@ dependencies = [
|
|||||||
"untrusted",
|
"untrusted",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sd-notify"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "621e3680f3e07db4c9c2c3fb07c6223ab2fab2e54bd3c04c3ae037990f428c32"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "security-framework"
|
name = "security-framework"
|
||||||
version = "2.7.0"
|
version = "2.7.0"
|
||||||
|
@ -93,8 +93,10 @@ tikv-jemallocator = { version = "0.5.0", features = ["unprefixed_malloc_on_suppo
|
|||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
async-trait = "0.1.57"
|
async-trait = "0.1.57"
|
||||||
|
|
||||||
|
sd-notify = { version = "0.4.1", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["conduit_bin", "backend_sqlite", "backend_rocksdb", "jemalloc"]
|
default = ["conduit_bin", "backend_sqlite", "backend_rocksdb", "jemalloc", "systemd"]
|
||||||
#backend_sled = ["sled"]
|
#backend_sled = ["sled"]
|
||||||
backend_persy = ["persy", "parking_lot"]
|
backend_persy = ["persy", "parking_lot"]
|
||||||
backend_sqlite = ["sqlite"]
|
backend_sqlite = ["sqlite"]
|
||||||
@ -103,6 +105,7 @@ backend_rocksdb = ["rocksdb"]
|
|||||||
jemalloc = ["tikv-jemalloc-ctl", "tikv-jemallocator"]
|
jemalloc = ["tikv-jemalloc-ctl", "tikv-jemallocator"]
|
||||||
sqlite = ["rusqlite", "parking_lot", "tokio/signal"]
|
sqlite = ["rusqlite", "parking_lot", "tokio/signal"]
|
||||||
conduit_bin = ["axum"]
|
conduit_bin = ["axum"]
|
||||||
|
systemd = ["sd-notify"]
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "conduit"
|
name = "conduit"
|
||||||
|
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 New Issue
Block a user