Start app as root with pm2

前端 未结 7 1619
遥遥无期
遥遥无期 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:21

    I would recommend:

    sudo pm2 start index.js
    

    OR

    pm2 start 'http-server' /var/www -p 80
    sudo pm2 startup
    pm2 save
    

    OR

    pm2 start 'which http-server' /var/www -p 80
    

    To start it on your HTTP Port

    Also, I always put -i 0 at the end - this starts up as many worker processes as you have cores. Check THIS

    It is not always necessary to start PM2 as root. If you have PM2 as root and the cli module installed, security is a big risk. This is only required if you're starting your app on a port between 1 and 1024

    0 讨论(0)
提交回复
热议问题