Node Process Managers

When I first used Node.js, for the first hour of development I was like ctrl+c,npm start, ctrl+c,npm start ... what a nightmare. Fortunately there are some nice people out there who "made it so". So we don't get RSI. Any time some file changes in our node directory the server is restarted for us. Excellent. There are quite a few of these packages out there. The ones I've used are listed below.

Killing

First of all I think it is good to mention that sometimes a process can run away with itself i.e. ctrl+c seems to kill the process, but then a few seconds later it pops up in your terminal and you're like wtf?!?!?

With forever you can use: forever stopAll

From a process id point of view, you can find out what processes are running on a given port:

lsof -i :5000

and then kill the process id:

kill -9 PIDNUMBER

To see all node services running do:

ps aux |grep node

Supervisor

To install:

npm install -g supervisor

To run:

supervisor app

The only problem with supervisor is that if there are any errors in your code, the server keeps starting and then crashing, starting and then crashing.

Nodemon

Nodemon is pretty cool.

To run:

nodemon app

Forever

Forever can be started in 3 ways.

forever start --uid "production" app.js

You can start your app using full path:

forever start /var/www/reports/app.js Reports

You also can add an unused command line param like:

forever start app.js project_name
forever start app.js DKFO Reports Preview

StrongLoop and PM2 are other ones are worth investigating too.

Go ahead and run.