Terminate cleanly on SIGINT
This commit is contained in:
@@ -160,6 +160,7 @@ pub async fn main(config: Config) -> Result<(), Error> {
|
|||||||
let mut alarm = signal(SignalKind::alarm()).expect("unable to listen for SIGALRM");
|
let mut alarm = signal(SignalKind::alarm()).expect("unable to listen for SIGALRM");
|
||||||
let mut child = signal(SignalKind::child()).expect("unable to listen for SIGCHLD");
|
let mut child = signal(SignalKind::child()).expect("unable to listen for SIGCHLD");
|
||||||
let mut term = signal(SignalKind::terminate()).expect("unable to listen for SIGTERM");
|
let mut term = signal(SignalKind::terminate()).expect("unable to listen for SIGTERM");
|
||||||
|
let mut int = signal(SignalKind::interrupt()).expect("unable to listen for SIGINT");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
@@ -169,6 +170,10 @@ pub async fn main(config: Config) -> Result<(), Error> {
|
|||||||
ctx.terminate().await.map_err(|e| format!("terminate: {}", e))?;
|
ctx.terminate().await.map_err(|e| format!("terminate: {}", e))?;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
_ = int.recv() => {
|
||||||
|
ctx.terminate().await.map_err(|e| format!("terminate: {}", e))?;
|
||||||
|
break;
|
||||||
|
}
|
||||||
stream = listener.0.accept() => match stream {
|
stream = listener.0.accept() => match stream {
|
||||||
Ok((stream, _)) => {
|
Ok((stream, _)) => {
|
||||||
let client_ctx = ctx.clone();
|
let client_ctx = ctx.clone();
|
||||||
|
Reference in New Issue
Block a user