Menu

1 / 3

Node Graceful Shutdown in Docker: Handle SIGTERM on Deploy

DEV Community: docker·GDS K S·5 days ago
#3VSwSON6
#devtodocker#devto#dev#exit#docker
Reading 0:00
15s threshold

A deploy that "works" can still reset in-flight requests. The old container gets a stop signal, your Node process does not react to it, and Docker kills it ten seconds later with whatever was in flight.

Part 4 of 7 in the Deploy and operate Levelrail series: 1. Install a Self-Hosted PaaS on Your Own Server in Five Minutes ; 2. Roll Back a Failed Docker Deploy Without Downtime ; 3. Restart a Docker Container Without Downtime ; 4. Node Graceful Shutdown in Docker: Handle SIGTERM on Deploy (this post); 5. Update the PHP Docker Image Security Patch, No Downtime ; 6. Docker Container Restarting in a Loop: 5 Causes, Fixed ; 7. Why a Failed Health Check Still Went Live .

In this guide we stop the same small Node server two ways, with and without a SIGTERM handler, count what clients see, then run both through Levelrail deploys under load. Every command and output below comes from a real run. The rough edges we hit are in their own section near the end.

What you need

Docker.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.