Categories
nodejs

Nodes Forever Package Doesn’t Mean Forever!

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.

description "AppName"
author "Aldo Lugo"

start on filesystem or runlevel [2345]
But, the main causes of ED problem in men and highly-admired by majority of medical professionals due to its soft cialis online  effective result in improving Erection problems. Medicines are order cheap levitra  highly effective when it comes to medical remedies as well. Those negative effects manifest in more than 1% of patients, taking Kamagra Polo regularly.Less common side effects include such as prolonged and painful erections, lightheadedness, vision changes, short breath, irregular heartbeat, ringing in the ears, chest pains and changes to the vision or hearing.  viagra sale in india Communication is about more than just exchanging  generic cialis samples information. stop on shutdown

script
    export HOME="/path"
    echo $$ > /var/run/appname.pid
    exec path/to/node /opt/app/server.js
end script

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