summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index bc3b8b7..6ea162b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,6 +2,7 @@ mod mattermost;
 use std::path::Path;
 
 use anyhow::anyhow;
+use tokio::signal::unix;
 use tokio::{self};
 use tracing::{debug, warn};
 
@@ -118,12 +119,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
                 .handle_websocket_stream(Vav::new(db), shutdown_recv)
                 .await
         });
-        match tokio::signal::ctrl_c().await {
-            Ok(()) => {}
-            Err(err) => {
-                eprintln!("Unable to listen for shutdown signal: {}", err);
-                // we also shut down in case of error
-            }
+        {
+            let mut sigterm = unix::signal(unix::SignalKind::terminate())?;
+            let mut sigint = unix::signal(unix::SignalKind::interrupt())?;
+            let mut sigquit = unix::signal(unix::SignalKind::quit())?;
+            tokio::select! {
+                signal = sigterm.recv() => signal,
+                signal = sigint.recv() => signal,
+                signal = sigquit.recv() => signal,
+            };
         }
         shutdown_send.send(())?;
         websocket_task.await??;