Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}

#[cfg(all(not(test), unix))]
async fn shutdown_signal() {
fn shutdown_signal() -> impl std::future::Future<Output = ()> {
// Shut down gracefully on SIGTERM (what container runtimes and the e2e test
// harness send) so in-flight requests drain and the process exits cleanly.
// Register eagerly before run_from_env publishes listener readiness; an
// async fn would not install the handler until its future was first polled.
let mut term = tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate())
.expect("install SIGTERM handler");
term.recv().await;
async move {
term.recv().await;
}
}

#[cfg(all(not(test), not(unix)))]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Non-unix path still installs handler lazily

The fix only touches the unix branch. The not(unix) branch remains an async fn, so tokio::signal::ctrl_c() installs only when the future is first polled inside run_from_env, after readiness. The startup race the PR closes on unix still exists on non-unix platforms.

(Refers to this code)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Expand Down
Loading