redup-bootstrap 0.3.0

Ядро платформы: инстанс службы, модули, жизненный цикл, здоровье и телеметрия.
Documentation
//! Сигналы остановки.

use std::io;

/// Ждёт сигнала завершения: SIGTERM или SIGINT.
pub(crate) async fn terminate() -> io::Result<()> {
    #[cfg(unix)]
    {
        use tokio::signal::unix::{SignalKind, signal};
        let mut terminate = signal(SignalKind::terminate())?;
        let mut interrupt = signal(SignalKind::interrupt())?;
        tokio::select! {
            _ = terminate.recv() => Ok(()),
            _ = interrupt.recv() => Ok(()),
        }
    }
    #[cfg(not(unix))]
    {
        std::future::pending::<()>().await;
        Err(io::Error::new(
            io::ErrorKind::Unsupported,
            "termination signals are not supported on this platform",
        ))
    }
}