fix: fixes unix specific impl of shutdown_signal (#1061)

This commit is contained in:
YummyOreo 2023-06-19 02:14:03 -05:00 committed by GitHub
parent b8b57c86af
commit 85c7339e65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,6 +14,7 @@ mod utils;
pub use settings::Settings; pub use settings::Settings;
use tokio::signal; use tokio::signal;
#[cfg(target_family = "unix")]
async fn shutdown_signal() { async fn shutdown_signal() {
signal::unix::signal(signal::unix::SignalKind::terminate()) signal::unix::signal(signal::unix::SignalKind::terminate())
.expect("failed to register signal handler") .expect("failed to register signal handler")
@ -22,6 +23,15 @@ async fn shutdown_signal() {
eprintln!("Shutting down gracefully..."); eprintln!("Shutting down gracefully...");
} }
#[cfg(target_family = "windows")]
async fn shutdown_signal() {
signal::windows::ctrl_c()
.expect("failed to register signal handler")
.recv()
.await;
eprintln!("Shutting down gracefully...");
}
pub async fn launch<Db: Database>( pub async fn launch<Db: Database>(
settings: Settings<Db::Settings>, settings: Settings<Db::Settings>,
host: String, host: String,