Ever wanted to deploy your node.js application on a server, but all you did was using
nohup node script.js &, because alternative solutions appeared to be to hard`
There is a nice tool from the nodejitsu folks called forever.
It is really simple to use
This will start your script using node and should it crash restart it, using sane defaults about when and how quickly these restarts happen.
Using coffee or not even node at all? Just use the
-c (--command) parameter.
forever -c coffee script.coffee
Using this option also allows forever to be used with non-node applications.
But wait there is more! Ever started an application and wished there was some straight forward way to restart your application on code change? Forever has yet another switch for this.
-w (or --watch)
forever -w script.js
This is all nice, but it's still nothing compared to a full-blown deamon, right? Well, no. forever offers even more. Once your app is running using forever you can use forever, like this:
forever stop script.js
forever start script.js
forever restart script.js
It also allows you to specify where logs (stderr/stdout) are going and much more. The nice thing about forever is that it scales well with your needs, always while the only requirement for getting it up and running is this:
npm -g install forever forever myscript.js