Start app as root with pm2

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

    If you only need your daemon to be run as root in order to access a port number (such as 80 or 443), the pm2 documentation recommends using authbind. So, if you want the user yourusername to have access to port 80, run:

    $ sudo apt-get install authbind
    $ sudo touch /etc/authbind/byport/80
    $ sudo chown yourusername /etc/authbind/byport/80
    $ sudo chmod 755 /etc/authbind/byport/80
    $ authbind --deep pm2 update
    

    And then use authbind --deep pm2 instead of pm2. The documentation suggests setting up an alias.

提交回复
热议问题