Start app as root with pm2

前端 未结 7 1644
遥遥无期
遥遥无期 2021-01-31 17:29

I have a daemon that must be run as root on startup.

I use pm2 to start other apps but can not figure out if it can start an app as root. Can it be done?

If not,

7条回答
  •  遇见更好的自我
    2021-01-31 18:17

    I had problems with sudo pm2 start api, but this was since pm2 was already running without sudo privileges, therefor you need to run:

    pm2 kill
    sudo pm2 start api
    

    This kills the pm2 deamon first, so that it starts in sudo, but then you need sudo for ALL pm2 commands afterwards, like: sudo pm2 ls

提交回复
热议问题