feat: add operational reconnect and shutdown handling
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
parent
b67248e14f
commit
10b8b24dce
@@ -0,0 +1,22 @@
|
||||
/// Cross-platform shutdown signal handling.
|
||||
///
|
||||
/// Provides a unified async future that resolves when the process should
|
||||
/// shut down (SIGINT/SIGTERM on Unix, Ctrl+C/Ctrl+Break on Windows).
|
||||
pub async fn shutdown_signal() {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use tokio::signal::unix::{SignalKind, signal};
|
||||
let mut sigint =
|
||||
signal(SignalKind::interrupt()).expect("failed to create SIGINT signal handler");
|
||||
let mut sigterm =
|
||||
signal(SignalKind::terminate()).expect("failed to create SIGTERM signal handler");
|
||||
tokio::select! {
|
||||
_ = sigint.recv() => {},
|
||||
_ = sigterm.recv() => {},
|
||||
}
|
||||
}
|
||||
#[cfg(not(unix))]
|
||||
{
|
||||
tokio::signal::ctrl_c().await.ok();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user