Frankie B
Frankie B

Reputation: 41

How can I make Forever run Node.js script on startup?

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!

Upvotes: 4

Views: 5990

Answers (1)

swogger
swogger

Reputation: 1119

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.

Upvotes: 5

Related Questions