When Kubernetes decides to stop a pod, it doesn't just kill the process — it sends a SIGTERM signal first and expects your app to wind down cleanly. This lesson walks through building that shutdown logic into a Node.js service.
Handling the Shutdown Signal
You'll learn what SIGTERM actually means for a running process, and why ignoring it leads to dropped requests, half-finished writes, and rough deploys.
Steps Covered
- Listening for SIGTERM inside your Node.js process
- Refusing new incoming requests once shutdown starts
- Letting in-flight work finish and cleaning up resources
- Closing the server only after everything is done
Why It Matters
A predictable shutdown sequence protects data, avoids sudden outages, and makes rolling deploys and autoscaling in Kubernetes far less risky. It's a small piece of code with an outsized effect on production stability.