If you proxy your Node.js application using Nginx, you can tell your Node application to listen on the socket, and then only close the old server if the new one starts correctly; as soon as the old server shuts down, Nginx will forward requests to the new server instance. Here's how Unicorn , the popular Ruby server, works.
In Nginx, you should specify your upstream as follows:
upstream node_server { server unix:/path/to/socket.sock; } server { ... location / { ... proxy_pass http:
And in node you can listen on socket with
server.listen('/path/to/socket.sock', function() { console.log("Listening on socket."); });
source share