Constantly running a NodeJS application

August 30, 2015 1.1k views
Linux Commands Linux Basics Node.js Applications

Hello there, DigitalOcean community!

I'm very new to Digital Ocean and in fact hosting in general, so I apologies prior if what you're about to read is an incredibly rookie question, but...

I've cloned a copy of a standard express (NodeJS) application on my droplet from a bitbucket repository and I can very easily run it via SSH using Nodemon (, however, as I'm executing the bin/www via the SSH connection, when I exit, the application stops running (as expected).

My question is, how do I configure my server so that Nodemon is always running my application on the server, I'm aware that there are 'services' or .conf files on Ubuntu which can be utilised to achieve such functionality, but I'm not sure how exactly I'd go about doing so...

Also, please correct me if I'm wrong, but if I do handle this via .conf / services, the service will automatically restart if for instance Digital Ocean does a mass droplet reload / update i.e after / during maintenance etc... Right?

Note: If this is a bad way of running a Node application on a server please let me know. I'd like to know the best / most efficient method(s) of doing this.

I appreciate any help, thanks in advance!

1 Answer

There's Node module called 'forever' or 'pm2', if you need clustering.
More info here

Have another answer? Share your knowledge.