How to use pm2 startup command on Debian platform?
Asked Answered
L

4

2

Here is the link to the documentation on GitHub: https://github.com/Unitech/pm2#startup-script-generation--pm2-startup

It is setup to work with Ubuntu/CentOS/Redhat. I need it to work with my Dreamhost VPS which is a Debian machine.

Can someone advise me on how I might tweak the init script to make it work on a Debian box? Thanks!!

Loco answered 2/2, 2014 at 3:1 Comment(0)
O
4

Try ubuntu solution. Since ubuntu is a debian fork, it should work there.

Oof answered 2/2, 2014 at 13:36 Comment(2)
Choosing ubuntu fails. I am getting the same error as stated in user2464266's answer.Loco
This no longer is giving me an error for some reason and looks successful, although it is not actually restarting my node service on reboot.Loco
M
12

If your vps is running the Jessie release (>8) then Jessie uses systemd not init.d (as ubuntu and older releases of debian do). Thus using the default ubuntu pm2 startup script won't work.

So if this is your case then all I did for this to work on my Jessie VM was

$ pm2 startup systemd

then pm2 start the node apps I want to start at bootup.

then

$ pm2 save

then give it a try.

$ shutdown -r now

of course do these from root

more details here. http://pm2.keymetrics.io/docs/usage/startup/

Mart answered 31/8, 2015 at 5:50 Comment(0)
O
4

Try ubuntu solution. Since ubuntu is a debian fork, it should work there.

Oof answered 2/2, 2014 at 13:36 Comment(2)
Choosing ubuntu fails. I am getting the same error as stated in user2464266's answer.Loco
This no longer is giving me an error for some reason and looks successful, although it is not actually restarting my node service on reboot.Loco
P
4

as the output suggests, you have to execute it as sudo:

sudo pm2 startup ubuntu
Prestige answered 26/2, 2014 at 9:16 Comment(0)
E
3

You can just add a cronjob like:

@reboot cd /path/to/app && pm2 start app.js

Remember to install the cron in the user that will run the daemon, NOT ROOT.

If you user can't install the cron, just install the cron where you prefer and add the parameter -u to specify the daemon runner user.

Eject answered 18/5, 2014 at 4:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.