Graceful shutdown for Node HTTP servers

3299
0

Deploys got a lot calmer once I treated SIGTERM as a first-class signal instead of an afterthought. In Kubernetes (and most PaaS platforms), you’re expected to stop accepting new requests quickly while finishing in-flight work. The worst failure mode I’ve seen is a container that keeps taking traffic while its dependencies are already draining, which turns into timeouts and noisy retries. I track open sockets so I can force-close them after a deadline, and I flip readiness to unhealthy as soon as shutdown begins. It’s not glamorous, but server.close() + a hard timeout gives you predictable behavior during rolling deploys and autoscaling.