Print message when stopping the daemon (SIGTERM)

systemd sends SIGTERM when stopping a service. When running in a tty,
CTRL + C (SIGINT) currently won't print a shutdown message.
This commit is contained in:
Elias Schriefer 2020-08-30 16:37:45 +02:00
parent bb51ff77b1
commit e6ffb3f3e1

View File

@ -55,6 +55,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Will (afaik) be stabilized in Rust 1.48 // Will (afaik) be stabilized in Rust 1.48
// core::future::pending::<()>().await; // core::future::pending::<()>().await;
loop {}; tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate())?.recv().await;
unreachable!(); info!("Got SIGTERM, shutting down");
Ok(())
} }