obelisk 0.37.3

Deterministic workflow engine
use tokio::{signal, sync::watch};
use tracing::warn;

pub(crate) async fn termination_notifier(termination_sender: watch::Sender<()>) {
    let ctrl_c = async {
        signal::ctrl_c()
            .await
            .expect("failed to install Ctrl+C handler");
    };

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

    #[cfg(not(unix))]
    let terminate = std::future::pending::<()>();

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

    warn!("Received shutdown signal");
    drop(termination_sender);
}