Constantly running a NodeJS application
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 (https://www.npmjs.com/package/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!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×