feat: refine signal handling and add config check to systemd reload

This commit is contained in:
2026-01-27 13:52:38 +08:00
parent a71e950734
commit 897237755f
4 changed files with 9 additions and 10 deletions

2
Cargo.lock generated
View File

@@ -3887,7 +3887,7 @@ dependencies = [
[[package]]
name = "traudit"
version = "0.0.6"
version = "0.0.7"
dependencies = [
"anyhow",
"async-trait",

View File

@@ -1,6 +1,6 @@
[package]
name = "traudit"
version = "0.0.6"
version = "0.0.7"
edition = "2021"
authors = ["awfufu"]
description = "A reverse proxy that streams audit records directly to databases."

View File

@@ -136,20 +136,18 @@ async fn main() -> anyhow::Result<()> {
Err(e) => error!("failed to spawn new process: {}", e),
}
// Initiate graceful shutdown for this process
info!("shutting down old process gracefully...");
info!("shutting down old process gracefully (draining connections)...");
let _ = shutdown_tx.send(());
// Wait for server to finish (graceful drain)
let _ = server_handle.await;
}
_ = sigint.recv() => {
info!("received SIGINT, shutdown...");
info!("received SIGINT, exiting immediately...");
}
_ = sigterm.recv() => {
info!("received SIGTERM, shutdown...");
info!("received SIGTERM, exiting immediately...");
}
}
// Send shutdown signal to server components
let _ = shutdown_tx.send(());
// Wait for server to finish (graceful drain)
let _ = server_handle.await;
Ok(())
}

View File

@@ -7,6 +7,7 @@ Type=notify
RuntimeDirectory=traudit
WorkingDirectory=/run/traudit
ExecStart=/usr/bin/traudit -f /etc/traudit/config.yaml
ExecReload=/usr/bin/traudit -f /etc/traudit/config.yaml -t
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGINT
Restart=on-failure