Headline: A graceful shutdown means a Node.js process that receives SIGTERM stops taking new work, finishes what is in flight, closes its database and Redis connections, and exits before the orchestrator's grace period ends. In a Dockerized NestJS app that takes an exec-form CMD , app.enableShutdownHooks() , and cleanup placed in the lifecycle hook that runs after the HTTP server drains.
Redeploying my containerized NestJS APIs used to cost a handful of 502s and, now and then, a queue job that ran twice. The logs showed no errors. The clue was in docker ps -a : the old containers ended with Exited (137) .…