Skip to content

Restart Node.js automatically

necroscope edited this page May 26, 2014 · 1 revision

Hi, I lost connection to mongolabs a few times which caused node to crash so I wanted node to auto restart node if this happens again. I decided to use a tool called forever to restart node if it crashes. Here is how to implement it: (**note some hosting services already use forever or this is in case they don't)

These steps where tested with Linux and Windows.  It is as simple as ABC
1. A) At the command prompt type:  sudo npm install forever -g
2. B) Once it is installed type: forever start server.js
3. C) To see if it is running type:  forever list

The github respository for forever is: https://github.com/nodejitsu/forever  
Clone this wiki locally