Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 9a4a0ae

Browse files
committed
cli/serve: integrate shutdown from upstream
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
1 parent d9865b3 commit 9a4a0ae

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/commands/serve.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,13 @@ impl ServeCommand {
564564
let next_id = Arc::new(AtomicU64::default());
565565
let cmd = Arc::new(self);
566566
loop {
567-
let (stream, _) = listener.accept().await?;
567+
// Wait for a socket, but also "race" against shutdown to break out
568+
// of this loop. Once the graceful shutdown signal is received then
569+
// this loop exits immediately.
570+
let (stream, _) = tokio::select! {
571+
_ = shutdown.requested.notified() => break,
572+
v = listener.accept() => v?,
573+
};
568574
let engine = engine.clone();
569575
let cmd = Arc::clone(&cmd);
570576
let next_id = Arc::clone(&next_id);

0 commit comments

Comments
 (0)