mirror of
https://github.com/awfufu/traudit
synced 2026-03-01 05:29:44 +08:00
feat: refine signal handling and add config check to systemd reload
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -3887,7 +3887,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "traudit"
|
||||
version = "0.0.6"
|
||||
version = "0.0.7"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
|
||||
@@ -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."
|
||||
|
||||
14
src/main.rs
14
src/main.rs
@@ -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(())
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user