Made a newbie mistake on my aws server. Started a node.js server as a user (node server.js &) and didn’t realize that after I logged out the node.js server would go down with it. Once I set the node.js to an upstart job it now start automatically and persistantly.
You have to create an upstart job. That way your app will start once linux loads, and you can start / stop / restart it by
sudo start yourapp,
sudo restart yourapp etc.
Here are the steps:
1) Install upstart utility
sudo apt-get install upstart
2) Create upstart script for your node app:
/etc/init add file
yourappname.conf with the following lines of code:
#!upstart description "your app name" start on started mountall stop on shutdown # Automatically Respawn: respawn respawn limit 99 5 env NODE_ENV=development exec node /path_to_your_app/app.js >> /var/log/yourappname.log 2>&1
3) start your app by
sudo start yourappname
sudo stop yourappname
sudo restart yourappname