
DevOps
Graceful Shutdown on Kubernetes for Rust Services Explained
When Kubernetes stops a pod, traffic keeps arriving for a moment after SIGTERM. A correct shutdown fails readiness, waits briefly, then drains requests before exiting.
3 min read
Tag
3 posts

When Kubernetes stops a pod, traffic keeps arriving for a moment after SIGTERM. A correct shutdown fails readiness, waits briefly, then drains requests before exiting.

Handle SIGTERM and Ctrl C so Axum finishes in-flight requests before exiting. Includes the signal future, the drain timeout and the Kubernetes and systemd details.

Shut down a Tokio service cleanly: catch SIGTERM and Ctrl+C, stop accepting work, wait for in flight tasks with TaskTracker, then exit within a deadline.