Skip to content

Commit 417358c

Browse files
authored
Patch graceful shutdown bug (#157)
* Fixes non-admin client counting error * Add log when sigterm received and log number of active clients when shutdown timeout is reached
1 parent 23a642f commit 417358c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pub async fn client_entrypoint(
204204
Ok(mut client) => {
205205
info!("Client {:?} connected (plain)", addr);
206206

207-
if client.is_admin() {
207+
if !client.is_admin() {
208208
let _ = drain.send(1).await;
209209
}
210210

@@ -229,7 +229,7 @@ pub async fn client_entrypoint(
229229
Ok(mut client) => {
230230
info!("Client {:?} issued a cancel query request", addr);
231231

232-
if client.is_admin() {
232+
if !client.is_admin() {
233233
let _ = drain.send(1).await;
234234
}
235235

src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,16 @@ async fn main() {
221221
interval.tick().await;
222222

223223
// We're done waiting.
224-
error!("Timed out waiting for clients");
224+
error!("Graceful shutdown timed out. {} active clients being closed", total_clients);
225225

226226
let _ = exit_tx.send(()).await;
227227
});
228228
},
229229

230-
_ = term_signal.recv() => break,
230+
_ = term_signal.recv() => {
231+
info!("Got SIGTERM, closing with {} clients active", total_clients);
232+
break;
233+
},
231234

232235
new_client = listener.accept() => {
233236
let (socket, addr) = match new_client {

0 commit comments

Comments
 (0)