Graceful shutdown

This commit is contained in:
Olivier 'reivilibre' 2021-07-09 21:20:05 +01:00
parent 0d50247e5c
commit 7560aefdd0
1 changed files with 10 additions and 8 deletions

View File

@ -7,7 +7,7 @@ use std::thread::JoinHandle;
use anyhow::anyhow;
use crossbeam_channel::{Receiver, Sender};
use itertools::Itertools;
use log::{error, warn};
use log::{error, info, warn};
use crate::pile::RawPile;
use crate::remote::{read_message, write_message, Request, RequestBody, Response, ResponseBody};
@ -80,6 +80,11 @@ impl Responder {
let request: Request = read_message(&mut read)?;
match request.body {
RequestBody::Shutdown => {
worker_queue_send.send(request)?;
info!("Shutting down responder");
return Ok(());
}
RequestBody::NextBatch { token } => {
let tokens = self
.continuation_tokens
@ -277,13 +282,10 @@ impl Responder {
}
}
},
RequestBody::Shutdown => {
warn!("Not yet implemented: Shutdown");
Response {
RequestBody::Shutdown => Response {
response_to: request.id,
body: ResponseBody::Success,
}
}
},
};
responses