implement-graceful-shutdown

Installation
SKILL.md

Summary

Backend services must listen for OS signals (like SIGTERM and SIGINT) and perform a Graceful Shutdown procedure. This ensures that no in-flight requests are dropped abruptly during deployments or scaling events.

Rationale

  • Zero Downtime: Rolling updates in Kubernetes or other orchestrators rely on the application handling SIGTERM to safely drain traffic.
  • Data Integrity: Ensures database transactions and open file handles are closed properly, not corrupted by a forced kill.

Guidance

  1. Listen: Use signal.Notify (Go) or process.on('SIGTERM') (Node.js) to catch signals.
  2. Stop: Stop the HTTP server from accepting new connections.
  3. Wait: Allow existing requests a timeout window (e.g., 5-30 seconds) to complete.
  4. Close: Close database connections, cache connections, and other resources.
  5. Exit: Exit the process with code 0.

Examples

Installs
1
First Seen
Apr 5, 2026
implement-graceful-shutdown — mew-ton/coding-guidelines