mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 05:25:40 +09:00
27 lines
721 B
Rust
27 lines
721 B
Rust
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
pub async fn wait_for_shutdown() {
|
|
let ctrl_c = tokio::signal::ctrl_c();
|
|
|
|
#[cfg(unix)]
|
|
{
|
|
use tokio::signal::unix::{SignalKind, signal};
|
|
let mut sigterm =
|
|
signal(SignalKind::terminate()).expect("failed to install SIGTERM handler");
|
|
tokio::select! {
|
|
_ = ctrl_c => {
|
|
tracing::info!("received SIGINT, beginning shutdown");
|
|
}
|
|
_ = sigterm.recv() => {
|
|
tracing::info!("received SIGTERM, beginning shutdown");
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(not(unix))]
|
|
{
|
|
ctrl_c.await.ok();
|
|
tracing::info!("received SIGINT, beginning shutdown");
|
|
}
|
|
}
|