Skip to main content

Module shutdown

Module shutdown 

Source
Expand description

Graceful shutdown signal.

Resolves on Ctrl+C or, on Unix, SIGTERM — the two signals a process manager (systemd, Docker, Kubernetes) or an interactive terminal sends to ask a server to stop accepting new work and drain in-flight requests.

Known limitation: if registering a signal handler itself fails (e.g. a sandboxed/seccomp-restricted environment that disallows the underlying syscalls), that branch logs an error and then never resolves — it does not abort the process, it just stops competing in the tokio::select! below so the other signal can still trigger shutdown. If both registrations fail, this future never resolves at all and the only way to stop the process becomes an uncatchable SIGKILL (no request draining). That failure mode is easy to miss: the only evidence is a startup-time log line, well before the eventual shutdown attempt that silently doesn’t work. Since SIGTERM is the primary signal process managers actually send, a failed SIGTERM registration in particular means production docker stop/kubectl delete pod shutdowns hard-kill instead of draining, not just Ctrl+C in a local terminal.

Functions§

shutdown_signal