Server ignores SIGTERM, so every container stop waits 10s and ends in SIGKILL #78
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
How found: reading
crates/breadboard-server/src/main.rswhile planning a low-downtime deploy of PR #76.Confidence: high for the SIGTERM part (code is unambiguous and Docker's PID 1 semantics are well known); medium for the SSE hang (follows from axum graceful shutdown semantics, not measured).
Explanation:
shutdown_signal()only awaitstokio::signal::ctrl_c()(SIGINT).docker stop/docker compose uprecreation sends SIGTERM. The server runs as PID 1 in the container, and PID 1 has no default SIGTERM action, so the signal is ignored. Docker then waits its 10s timeout and SIGKILLs. Result: every deploy or restart is about 10s of downtime instead of under 1s. Separately, even with SIGTERM handled,with_graceful_shutdownwaits for in-flight responses, and/eventsSSE streams never end on their own, so shutdown would still hang until the kill while any browser tab is open.Fix idea: also listen for
SignalKind::terminate(), and on shutdown end the SSE streams (e.g. a shutdownwatch/CancellationTokenthat the events stream selects on), so open tabs disconnect immediately and EventSource reconnects to the new container. Optionally addstop_grace_period/STOPSIGNALin the Containerfile/compose.Workaround used meanwhile:
docker compose up -d --timeout 1(SQLite WAL is crash-safe).Implemented in PR #81: #81. The server now handles SIGTERM and closes active SSE streams during graceful shutdown.
cargo build --workspace,cargo test --workspace,cargo clippy --workspace --all-targets -- -D warnings,cargo run -p xtask -- check-docs, andgit diff --checkpass.cargo fmt --all -- --checkreports pre-existing formatting drift in untouched files.Board cleanup 2026-10-08: rebased PR #81 onto main (
707b758). One conflict inhttp.rs: main's BB-90 refactor moved SSE mapping intoevent_stream(), so the shutdowntake_untilnow wrapsevent_stream(...)and keeps the lag-ends-stream behaviour. After the rebase the SIGTERM integration test got a 401 because BB-93 made/eventsrequire auth. Fixed by minting a bearer token in the server DB once it is healthy. Workspace tests and server clippy pass. The remainingcargo fmt --checkdrift is pre-existing on main and not from this PR. Reviewed the signal handling: SIGTERM and SIGINT both trigger shutdown, the watch flag closes open SSE streams so graceful shutdown no longer hangs, and the non-unix fallback is intact. Ready to merge once CI is green.