From 83a1af59d9a413ff8d145d94b7deb434dba93a3b Mon Sep 17 00:00:00 2001 From: Neshura Date: Tue, 12 Dec 2023 21:15:50 +0100 Subject: [PATCH] General SIGINT handling instead of CTRLC handling --- src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index f1df875..fd57680 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,7 @@ use chrono::Local; use actix_web::{middleware::Logger, web, App, HttpServer}; use serde::{Deserialize, Serialize}; use sqlx::{PgPool, Pool, Postgres, Connection}; +use tokio::signal::unix::SignalKind; use utoipa::{OpenApi, openapi::security::{SecurityScheme, ApiKey, ApiKeyValue}, Modify}; use utoipa_swagger_ui::{Config, SwaggerUi, Url}; @@ -249,8 +250,8 @@ async fn main() { let watchdog_thread = tokio::spawn(async move { postgres_watchdog(pool_copy, shutdown_clone).await }); tokio::spawn(async move { - actix_web::rt::signal::ctrl_c().await.unwrap(); - println!("Ctrl-C received, killing Server"); + actix_web::rt::signal::unix::signal(SignalKind::interrupt()).unwrap().recv().await; + println!("SIGINT received, killing Server"); abort() });