Last Updated: February 25, 2016
·
569
· guerre50

How to keep nodeJS app running

Just add a file into /etc/init with execute rights with following content:

#!upstart
description "app-name"

start on started mountall
stop on shutdown

# Automatically respawn:
respawn
respawn limit 99 5

env NODE_ENV=production

exec node /path/to/node/app/app.js >> /var/log/app-name.log 2>&1

You can access the app as a service executing any of the typical actions (start, stop and restart):

action app-name