Switch language한국어
Back to the list

Why Won't Node.js Containers Shut Down Cleanly? (feat. Graceful Shutdown)

TL;DR AI

Key summary

2 min read
  1. A Node.js container had a graceful shutdown issue where it did not stop on termination signals and eventually reached SIGKILL.

  2. The root cause was identified as Linux PID 1 signal-handling behavior plus lingering async work in the Node.js event loop.

  3. The fix was to run dumb-init as PID 1 and add timeouts to NestJS shutdown hooks.

  4. Kubernetes terminationGracePeriodSeconds was also increased to give the process enough time to exit cleanly.

Read the original