Skip to content

feat: improve graceful shutdown drain visibility#263

Merged
kacy merged 1 commit intomainfrom
feat/graceful-shutdown
Feb 24, 2026
Merged

feat: improve graceful shutdown drain visibility#263
kacy merged 1 commit intomainfrom
feat/graceful-shutdown

Conversation

@kacy
Copy link
Owner

@kacy kacy commented Feb 24, 2026

summary

improves the drain_connections function to log the active connection count when shutdown begins and the remaining connection count if the 30-second timeout expires. this gives operators better visibility into shutdown progress — previously the logs only said "waiting for connections..." with no count, and "timeout" with no indication of how many connections were stuck.

also reviewed the full shutdown path for both concurrent and threaded modes. both are solid:

  • concurrent mode: ctrl_c breaks accept loop → drain_connections (30s timeout) → exit
  • threaded mode: ctrl_c → notify workers → workers break accept loops → rt.shutdown_timeout(30s) per worker → join threads

no behavioral changes, just better observability during shutdown.

what was tested

  • cargo test -p ember-server — all 137 tests pass
  • cargo check -p ember-server — clean compile
  • manual review of both shutdown code paths (concurrent + threaded)

design considerations

kept the change minimal — the drain timeout and semaphore-based mechanism are already correct. the only gap was that operators couldn't see how many connections were active or stuck during shutdown. the saturating_sub on available permits gives an accurate count since each connection holds exactly one permit.

log active connection count when drain starts and remaining count
if the 30s timeout expires, giving operators visibility into shutdown
progress.
@kacy kacy merged commit 0f97fd6 into main Feb 24, 2026
6 of 7 checks passed
@kacy kacy deleted the feat/graceful-shutdown branch February 24, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant