Let’s say I have a nodejs/express application on production server. If I want to add a new router, I have to reboot one, right? But if I reboot my node.js server, then users could get an error.
So how should I reboot my node.js server without errors for my users?
If you proxy to your Node.js app with Nginx, you can tell your Node app to listen on a socket and then only shut down the old server if the new one starts correctly; once the old server shuts down, Nginx will route requests to the new instance of the server. This is how Unicorn, a popular Ruby server, works.
In Nginx, you would specify your upstream like this:
And in node, you can listen on a socket with