forever is helpful function to create applications that are always running node.js to "forever". It's easy to install on your Ubuntu or Debian system, Forever is  used to If the application dies, forever brings it back and running node.js scripts. 

How to Install:

Let's install this using npm package and the npm should have been installed as part of Node.js.

$ sudo apt-get update

$ sudo apt-get install git-core curl build-essential openssl libssl-dev

Install forever function using the below command,

$ sudo npm install forever --global

To start and stop the node.js using forever command,

$sudo  forever start node.js 

warn:    --minUptime not set. Defaulting to: 1000ms
warn:    --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info:    Forever processing file: node.js

$ sudo  forever stop node.js 

info:    Forever stopped process:
    uid  command         script    forever pid  id logfile                 uptime        
[0] v2oC /usr/bin/nodejs node.js 1979    1984    /root/.forever/v2oC.log 5:0:11:35.930