1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::sync::Arc;
use tokio::signal::unix::SignalKind;
use crate::platform::Platform;
pub fn install(platform: Arc<Platform>) {
let _ = tokio::spawn(async move {
let ctrl_c = tokio::signal::ctrl_c();
let mut sig_hup = tokio::signal::unix::signal(SignalKind::hangup()).unwrap();
tokio::select! {
_ = ctrl_c => {
log::info!("Received CTRL-C. Shutting down...");
platform.terminate();
},
_ = sig_hup.recv() => {
log::info!("Received SIGHUP. Shutting down...");
platform.terminate();
}
}
});
}