简体   繁体   English

有没有办法以 pm2 以 root 身份启动节点应用程序?

[英]Is there a way to start a node application with pm2 running as root?

I have a node express app used as GUI for an embedded raspberry pi controller that manipulates a device via the gpio interface.我有一个 node express 应用程序用作嵌入式树莓派 controller 的 GUI,它通过 gpio 接口操作设备。 The app runs fine with the command "sudo node app.js", but fails if I try to run it with the command "node app.js" with the error...该应用程序使用命令“sudo node app.js”运行良好,但如果我尝试使用命令“node app.js”运行它并出现错误...

2022-08-28 21:48:03 initCheckPermitted: 
+---------------------------------------------------------+
|Sorry, you don't have permission to run this program.    |
|Try running as root, e.g. precede the command with sudo. |
+---------------------------------------------------------+
/home/ko2f/resonate/node_modules/pigpio/pigpio.js:17
    pigpio.gpioInitialise();

I would like to use pm2 to automatically run my app each time the controller restarts.每次 controller 重新启动时,我想使用 pm2 自动运行我的应用程序。

Is there a way to start a node application with pm2 running as root?有没有办法以 pm2 以 root 身份启动节点应用程序?

Like your messages says.就像你的消息说的那样。

Try using sudo before your command尝试在命令之前使用sudo

sudo pm2 start server.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM