Start Node JS application when server reboots with pm2
Asked Answered
B

2

3

I am trying to use the module pm2 to start my node js app everytime the server boots. I have used the command pm2 startup ubuntu but each time I restart the server, my application is not running and I have to start it manually again.

Any ideas what is causing this issue?

Beriberi answered 17/8, 2015 at 14:54 Comment(3)
put some of your code here please, its quite impossible to suggest a solution otherwise.Downcomer
@Downcomer what difference would his code make? this is a question of starting a node app automatically on reboot.Karylkarylin
what does pm2 logs say?Nihilism
N
11

Make sure you do save your processes:

pm2 start app.js 
pm2 startup ubuntu 
pm2 save

Once you have started the apps and want to keep them on server reboot do: pm2 save

Source: https://github.com/Unitech/PM2/blob/master/ADVANCED_README.md#startup-script

Nihilism answered 17/8, 2015 at 17:52 Comment(1)
H
0

Go to your server directory and use the following commands:

pm2 start <your_app_name.js>
pm2 startup ubuntu
pm2 save
Hornswoggle answered 3/9, 2016 at 4:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.