[英]PM2 run task requiring 'sudo'
I have a task that must be run using sudo (sets up a listener on a low port).我有一个必须使用 sudo 运行的任务(在低端口上设置侦听器)。 Is there a way to specify this in a pm2 json start file declaration?
有没有办法在 pm2 json 开始文件声明中指定它?
I did some research after VeXii's comment and found one way to get access to privileged ports that works for me.我在 VeXii 的评论之后做了一些研究,并找到了一种访问对我有用的特权端口的方法。 on an Unbuntu system,
在 Unbuntu 系统上,
sudo apt-get install libcap2
Then arrange for setcap to be run before node is started.然后安排 setcap 在节点启动之前运行。 in my case I put the following in rc.local, but it could be run from .bashrc or .profile in a user account by adding 'sudo' to the comand.
在我的情况下,我将以下内容放在 rc.local 中,但可以通过在命令中添加“sudo”来从用户帐户中的 .bashrc 或 .profile 运行它。
setcap "cap_net_bind_service=+ep" /usr/bin/nodejs
What this does is to allow any program run by node to access any privileged port on the system.这样做的目的是允许节点运行的任何程序访问系统上的任何特权端口。
I'd like a finer grained solution but this got me going.我想要一个更细粒度的解决方案,但这让我继续前进。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.