本文介绍了是否以 root 身份启动 supervisord?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Supervisor 正在 3.0 上运行:

Supervisor is running on 3.0:

pip freeze | grep supervisor
supervisor==3.0

从命令行启动 supervisord 时:

When starting supervisord from the command line:

sudo $VIRTENV/supervisord --nodaemon --configuration $PATH_TO_CONFIG/supervisord.conf

我收到此错误:

2013-11-11 23:30:50,205 CRIT Supervisor running as root (no user in config file)

但是如果没有 sudo,我无法启动 supervisord,它会抱怨:

But I can't start supervisord without sudo, it complains:

Error: Cannot open an HTTP server: socket.error reported errno.EACCES (13)

正确的处理方式是什么?

What is the right way to deal with it?

(如果以 root 身份启动,但在 supervisord.conf 中的 [supervisord] 部分下设置 user = foobar,我得到同样的错误)

(I get the same error if starting it as root but setting user = foobar under the [supervisord] section in supervisord.conf)

更新:这是我的 supervisord.conf

Update: Here is my supervisord.conf

[unix_http_server]
file = /opt/run/supervisord.sock

[inet_http_server]
port = 9001
username = foobar
password = foobar

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisord]
logfile = /opt/logs/supervisord.log
loglevel = debug
pidfile = /opt/run/supervisord.pid

[supervisorctl]

[program:foo1]
user = foobar
autostart = True
autorestart = True
command = foo1
stdout_logfile = /opt/logs/foo1.stdout.log
stderr_logfile = /opt/logs/foo1.stderr.log
stdout_logfile_maxbytes = 10MB
stderr_logfile_maxbytes = 10MB

[program:foo2]
user = foobar
autostart = true
autorestart = true
command = foo2
priority = 100
stdout_logfile_backups = 0
stderr_logfile_backups = 0
stdout_logfile_maxbytes = 10MB
stderr_logfile_maxbytes = 10MB
stdout_logfile = /opt/logs/foo2.stdout.log
stderr_logfile = /opt/logs/foo2.stderr.log

推荐答案

Supervisord 在任何处理之前切换到 UNIX 用户帐户.

Supervisord switches to UNIX user account before any processing.

您需要指定它应该使用什么样的用户帐户,以root身份运行守护程序但在配置文件中指定用户

You need to specify what kind of user account it should use, run the daemon as root but specify user in the config file

示例:

[program:myprogram]
command=gunicorn --worker-class socketio.sgunicorn.GeventSocketIOWorker app.wsgi:application -b 127.0.0.1:8000
directory=/opt/myprogram
user=user1
autostart=true
autorestart=true
redirect_stderr=True

访问 http://supervisord.org/configuration.html#program-x-section-values 了解更多信息

这篇关于是否以 root 身份启动 supervisord?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-29 05:31