Skip to content

Commit

Permalink
we're on unix
Browse files Browse the repository at this point in the history
  • Loading branch information
thejefflarson committed Feb 28, 2025
1 parent 109470e commit 25ce542
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use tokio::signal::{
ctrl_c,
unix::{signal, SignalKind},
};

pub(crate) async fn shutdown_signal() {
let ctrl_c = async {
ctrl_c().await.expect("failed to install Ctrl+C handler");
};

let terminate = async {
signal(SignalKind::terminate())
.expect("failed to install signal handler")
.recv()
.await;
};

tokio::select! {
_ = ctrl_c => {},
_ = terminate => {},
}
}

0 comments on commit 25ce542

Please sign in to comment.