How to use pm2 startup command on Debian platform?

 ̄綄美尐妖づ 提交于 2019-12-06 14:26:59

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

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/

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

sudo pm2 startup ubuntu

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!