[英]Launch pm2 as superuser
I'm trying to launch node.js application with pm2. 我正在尝试使用pm2启动node.js应用程序。 I've installed pm2:
sudo npm install pm2 -g
我已经安装了pm2:
sudo npm install pm2 -g
Now, if I launch pm2 as non-root user it works fine. 现在,如果我以非root用户身份启动pm2,则可以正常工作。 But if I try to run:
sudo pm2 logs
I have an error: pm2: command not found
但是,如果我尝试运行:
sudo pm2 logs
则会出现错误: pm2: command not found
pm2 logs
works fine pm2 logs
If I use a sh-script to launch: sudo sh run.sh
there is another error in logs: 如果我使用sh脚本启动:
sudo sh run.sh
,则日志中还会出现另一个错误:
events.js:72
throw er; // Unhandled 'error' event
^ Error: connect EACCES
How can I launch pm2 as super-user, to make sure that other users can launch and restart applications with sudo pm2 monit
or sudo pm2 restart appname
etc..? 如何以超级用户身份启动pm2,以确保其他用户可以使用
sudo pm2 monit
或sudo pm2 restart appname
等启动和重新启动应用程序?
Most apparently pm2
is not listed in the PATH
for root. 显然,
pm2
没有在root的PATH
列出。
Check if the PATH
for non-root and root users are the same like this 检查非root用户和root用户的
PATH
是否相同
$ echo 'echo $PATH' | sh
$ echo 'echo $PATH' | sudo sh
if not add the missing path for pm2
for root 如果没有,则为根添加
pm2
的缺少路径
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.