Node.js · Senior · Question 67 of 75
Why does a Node.js process need a strategy for SIGINT/SIGTERM when it runs as PID 1 in a container?
- 1PID 1 can't open sockets
- ✓Correct answer: PID 1 gets no default signal handling, so without handlers (or an init like
tini/--init) the container may ignore stop signals until it's killed - 3Signals are not delivered to containers
Explanation
Start Node.js directly (CMD ["node", "server.js"]), not through npm start, which may not forward signals, and handle SIGTERM for graceful shutdown.