Node.js: running apps in a production environment on Ubuntu Server 14.04

Node.js: running apps in a production environment on Ubuntu Server 14.04

On Ubuntu Server 14.04 we can manage Node.js apps with the upstart service.

On Ubuntu Server 14.04 we can manage Node.js apps with the upstart service.

We need to create a .conf file in /etc/init (e.g. app.conf) with the following contents:


start on filesystem and started networking
stop on shutdown
respawn
setuid username
chdir /home/username/app
exec /usr/local/bin/node app.js

Your app will run as a service with the selected user as a owner even at boot time (and, obviously, reboot) and you will be able to manage it with the service command followed by the name of the .conf file. For example:


sudo service app restart