Expand description
Graceful shutdown handling for ReasonKit Web server
This module provides comprehensive shutdown handling including:
- Signal handling (SIGTERM, SIGINT)
- Graceful connection draining
- Systemd watchdog integration
- Health status management during shutdown
§Architecture
Signal (SIGTERM/SIGINT)
│
▼
┌───────────────────┐
│ ShutdownController│──────────▶ Notify all subscribers
└───────────────────┘
│
▼
┌───────────────────┐
│ Stop new requests │
└───────────────────┘
│
▼
┌───────────────────┐
│ Drain in-flight │◀──── timeout: 30s default
└───────────────────┘
│
▼
┌───────────────────┐
│ Flush logs │
└───────────────────┘
│
▼
┌───────────────────┐
│ Clean exit │
└───────────────────┘Modules§
- axum_
integration - Axum layer/middleware for graceful shutdown
Structs§
- Connection
Guard - RAII guard for tracking active connections
- Health
Status - Health check response during shutdown
- Shutdown
Controller - Shutdown controller that manages graceful shutdown
Enums§
- Shutdown
State - Shutdown state enum
Constants§
- DEFAULT_
DRAIN_ TIMEOUT_ SECS - Default drain timeout for in-flight requests
- DEFAULT_
SHUTDOWN_ TIMEOUT_ SECS - Default graceful shutdown timeout in seconds
Functions§
- shutdown_
signal - Create a shutdown signal future for use with Axum’s graceful shutdown
- shutdown_
signal_ with_ controller - Create a shutdown signal future with a controller for advanced shutdown handling
- systemd_
notify_ ready Linux - Notify systemd that the service is ready
- systemd_
notify_ status Linux - Notify systemd with a status message
- systemd_
notify_ stopping Linux - Notify systemd that the service is stopping
- systemd_
watchdog_ ping Linux - Send watchdog ping to systemd
- watchdog_
task - Watchdog task that periodically pings systemd