Skip to content

Commit 803930b

Browse files
committed
handle both sigint and sigterm
1 parent bfd8599 commit 803930b

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/dist/server.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,12 +446,21 @@ impl Server {
446446
res.map_err(|e| e.into())
447447
};
448448

449-
// Install our own SIGINT handler so pending jobs can bail early and
450-
// record server_terminated responses. This gives the client a chance
451-
// to retry the job or build locally.
449+
// Install our own handlers so pending jobs can bail early and record
450+
// server_terminated responses. This gives the client a chance to retry
451+
// the job or build locally.
452452
let sigint = async {
453-
let _ = tokio::signal::ctrl_c().await;
454-
tracing::info!("Received SIGINT");
453+
use tokio::signal::unix::{signal, SignalKind};
454+
let mut sigint = signal(SignalKind::interrupt())?;
455+
let mut sigterm = signal(SignalKind::terminate())?;
456+
futures::select_biased! {
457+
_ = sigint.recv().fuse() => {
458+
tracing::info!("Received SIGINT");
459+
},
460+
_ = sigterm.recv().fuse() => {
461+
tracing::info!("Received SIGTERM");
462+
},
463+
}
455464
Ok(())
456465
};
457466

0 commit comments

Comments
 (0)