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]]
|
[[package]]
|
||||||
name = "traudit"
|
name = "traudit"
|
||||||
version = "0.0.6"
|
version = "0.0.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "traudit"
|
name = "traudit"
|
||||||
version = "0.0.6"
|
version = "0.0.7"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["awfufu"]
|
authors = ["awfufu"]
|
||||||
description = "A reverse proxy that streams audit records directly to databases."
|
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),
|
Err(e) => error!("failed to spawn new process: {}", e),
|
||||||
}
|
}
|
||||||
// Initiate graceful shutdown for this process
|
// 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() => {
|
_ = sigint.recv() => {
|
||||||
info!("received SIGINT, shutdown...");
|
info!("received SIGINT, exiting immediately...");
|
||||||
}
|
}
|
||||||
_ = sigterm.recv() => {
|
_ = 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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ Type=notify
|
|||||||
RuntimeDirectory=traudit
|
RuntimeDirectory=traudit
|
||||||
WorkingDirectory=/run/traudit
|
WorkingDirectory=/run/traudit
|
||||||
ExecStart=/usr/bin/traudit -f /etc/traudit/config.yaml
|
ExecStart=/usr/bin/traudit -f /etc/traudit/config.yaml
|
||||||
|
ExecReload=/usr/bin/traudit -f /etc/traudit/config.yaml -t
|
||||||
ExecReload=/bin/kill -HUP $MAINPID
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
KillSignal=SIGINT
|
KillSignal=SIGINT
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|||||||
Reference in New Issue
Block a user