I run most of my node apps on a droplet with DigitalOcean. Recently there was an issue and the droplet had to be restarted by them, but my app didn’t restart. This was a big issue for me and my client. I use Forever to run the app, but this only works if the app crashes and not when the server is rebooted.

The solution to this is to use an Upstart script. The one below is an example of one I use, as you can see its pretty small. The scripts can get rather complex and it all depends on your needs.

The scripts need to live in /etc/init/ directory and with a .conf file extension.

The script can be started by running sudo service appname start.