How to deploy changes without service interruption?

I'm about to start a project with Node, Express and Mongo, but there is one important question that I have to solve first.

Say I have a running application. Sooner or later, I will code again and want to deploy changes. Until now, I've worked in development mode only, so it's not a problem to do a ^C and restart the server.

How about in the production ? Obviously I can't just trash the server and all the users at once. Is there any way to deploy changes without interrupting the service ?

I've looked into systems like upstart and similar, but it doesn't solve the problem (or did I miss anything?). I'm currently considering building a kind of failover, but someone must have done that before me...

Well, I'll probably go with a reverse proxy like nginx: low memory footprint, able to handle lots of simultaneous connections and supports failover when I'll finally have more than one server.

With this nginx reverse proxy, I can start a new Node process with the updated sources, have nginx switch to the new Node and trash the old version.

This will also allow me to keep previous version of the app on the server, just in case the new version crashes too early...

Links: http://nginx.org/en/docs/control.html

Checkout Forever by NodeJitsu. It daemonizes the process and automatically restarts the server when something fails. It also has an option to watch your CWD so if you do a "git pull" in your repo, your server is restarted with the new code.

I have used this in production as a pull based server model for over a year now and have had little to no problems.

If you care about availability, then you have to run your service on multiple servers, preferably in different physical locations. Lots of events besides a deploy can take a single server offline. So there's no problem, you take each server offline, deploy to it, and put it back online.

If you don't care about availability, there's still no problem.