Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 44 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,18 +255,54 @@ fn shutdown_signal_listener(core_tx: UnboundedSender<CoreMessages>) -> JoinHandl
debug!("Starting the shutdown signal listener");

tokio::spawn(async move {
signal::ctrl_c()
.await
.expect("failed to listen for the terminal interrupt signal");

info!("Terminal interrupt signal received, send another to force immediate shutdown");

tokio::spawn(async {
let ctrl_c = async {
signal::ctrl_c()
.await
.expect("failed to listen for the terminal interrupt signal");
};

#[cfg(target_family = "unix")]
let terminate = async {
signal::unix::signal(signal::unix::SignalKind::terminate())
.expect("failed to install the terminate signal handler")
.recv()
.await;
};

#[cfg(target_family = "windows")]
let terminate = std::future::pending::<()>();

tokio::select! {
() = ctrl_c => {},
() = terminate => {},
}

info!("Termination signal received, send another to force immediate shutdown");

tokio::spawn(async {
let ctrl_c = async {
signal::ctrl_c()
.await
.expect("failed to listen for the terminal interrupt signal");
};

#[cfg(target_family = "unix")]
let terminate = async {
signal::unix::signal(signal::unix::SignalKind::terminate())
.expect("failed to install the terminate signal handler")
.recv()
.await;
};

#[cfg(target_family = "windows")]
let terminate = std::future::pending::<()>();

tokio::select! {
() = ctrl_c => {},
() = terminate => {},
}

warn!("Second terminal interrupt signal received, forcing immediate shutdown");
warn!("Second termination signal received, forcing immediate shutdown");
process::exit(130);
});

Expand Down