Skip to main content

Module shutdown

Module shutdown 

Source
Expand description

Shutdown signal and background tasks

When the server is asked to stop (CTRL+C, SIGTERM, or the future given to App::serve_with_shutdown completes) it stops accepting connections, tells idle keep-alive connections to close, lets in-flight requests finish, and waits for background tasks, each at most App::shutdown_grace (default 10 s). Long-lived work such as SSE streams, WebSocket handlers and periodic jobs should watch Shutdown to end promptly instead of running into that limit.

Structsยง

Context
Handed to every task registered with App::background; cheap to clone into sub-tasks
Shutdown
Resolves when the server begins shutting down