In the simple chat example that we started with, the server will shutdown and stop running once you log out or stop it with cntrl-c. Forever is a node module that allows us to run a node server in the background.
Install the module:
npm install forever -g
Then run the server with it:
forever start server.js
List running servers (running using forever)
forever list
This should output a list of running forever scripts
info: Forever processes running
data: uid command script forever pid logfile uptime
data: [0] GpWl /usr/local/bin/node server.js 16677 16679 /root/.forever/GpWl.log 0:0:0:14.683
This shows one process running with the ID of GpWl (which is important if you want to shut it down). It’s log file is here: /root/.forever/GpWl.log which is where any output that it generates will be written.
Stop it
forever stop <enter the pid>
(see above for the ID)