4

I am running forever for my node.js which is great, but when the server restarts I have to rerun the command. Are there any suggestions on how to make it so on reboot or start up, forever automatically launches the script.

Lets say its

forever /var/www/server.js

Thank you!

Frankie B
  • 41
  • 1
  • 2
  • 1
    possible duplicate of http://stackoverflow.com/questions/15013248/forever-does-not-start-on-server-reboot/15013844#comment21093996_15013844 – Pascal Belloncle Feb 22 '13 at 06:41
  • Assuming linux, you could make a sysvinit script for it, look at scripts in /etc/init.d/ and [any guide](https://www.google.nl/search?q=making+a+sysvinit+script&oq=making+a+sysvinit+script&aqs=chrome.0.57.3977&sourceid=chrome&ie=UTF-8). – mtsr Feb 22 '13 at 15:17

1 Answers1

5

Edit crontab:

   $ sudo crontab -e

The first time it will ask you which editor you wish to edit with.

Once in the editor add the following line:

   @reboot /usr/local/bin/forever start /your/path/to/your/app.js

Save the file.

Reboot.

swogger
  • 1,079
  • 14
  • 30