使用pm2以root身份启动应用程序 [英] Start app as root with pm2

查看:834
本文介绍了使用pm2以root身份启动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个守护程序,必须在启动时以root身份运行.

I have a daemon that must be run as root on startup.

我使用pm2启动其他应用程序,但无法确定它是否可以以root用户身份启动应用程序.能做到吗?

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, what are my options?

推荐答案

我遇到了sudo pm2 start api的问题,但这是因为pm2已经在没有sudo特权的情况下运行,因此您需要运行:

I had problems with sudo pm2 start api, but this was since pm2 was already running without sudo privileges, therefor you need to run:

pm2 kill
sudo pm2 start api

这首先杀死了pm2守护进程,所以它以sudo开头,但是随后您需要sudo来执行 ALL pm2命令,例如:sudo pm2 ls

This kills the pm2 deamon first, so that it starts in sudo, but then you need sudo for ALL pm2 commands afterwards, like: sudo pm2 ls

这篇关于使用pm2以root身份启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆