pub fn install_signal_handler() -> CancellationTokenExpand description
Wait for SIGTERM or SIGINT, then trigger shutdown.
Call this once at application startup. It spawns a background task that waits for the OS signal, then cancels the global token.
K8s pre-stop compliance: When running in Kubernetes (detected via
crate::env::runtime_context), sleeps for PRESTOP_DELAY_SECS
(default 5) before cancelling the token. This gives K8s time to
remove the pod from Service endpoints before the app starts draining.
On bare metal / Docker, the delay is 0 (immediate shutdown).
Returns the token for use in tokio::select! or other async
shutdown coordination.