主管 celeryd 的用户不正确
我有一些使用 celery 运行的定期任务(由supervisord 守护),但是在尝试在用户的主目录中创建一个目录后,我为supervisord 进程设置了一个“权限被拒绝”错误。在查看正在运行的 celery 任务中的 os.environ 字典后,我注意到 USER var 设置为“root”,而不是我在 Supervisord 中设置的用户芹菜的配置。
这就是我的 /usr/local/etc/supervisord.conf
的样子:
[unix_http_server]
file=/tmp/supervisor.sock
chmod=0777
[supervisord]
logfile=/var/log/supervisord.log
pidfile=/var/run/supervisord.pid
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock
[program:celery]
command=/home/<USER>/.virtualenvs/sync/bin/celeryd --beat --loglevel=INFO
environment=PYTHONPATH=/home/<USER>/apps/sync
directory=/home/<USER>/apps/sync
user=<USER>
numprocs=1
stdout_logfile=/var/log/celeryd.log
stderr_logfile=/var/log/celeryd.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 30
可能是什么原因造成的?任何帮助将不胜感激!
I have some periodic tasks that I run with celery (daemonized by supervisord), but after trying to create a directory in the home dir for the user i setup for the supervisor'd process I got a "permission denied" error. After looking at the os.environ
dict in a running celery task I noticed that the USER
var is set to 'root' and not the user that I set up in my supervisord config for celery.
This is what my /usr/local/etc/supervisord.conf
looks like:
[unix_http_server]
file=/tmp/supervisor.sock
chmod=0777
[supervisord]
logfile=/var/log/supervisord.log
pidfile=/var/run/supervisord.pid
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock
[program:celery]
command=/home/<USER>/.virtualenvs/sync/bin/celeryd --beat --loglevel=INFO
environment=PYTHONPATH=/home/<USER>/apps/sync
directory=/home/<USER>/apps/sync
user=<USER>
numprocs=1
stdout_logfile=/var/log/celeryd.log
stderr_logfile=/var/log/celeryd.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 30
What could be causing this? Any help would be super appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这是由于您没有设置 HOME 和 USER 环境变量引起的。如果您的子流程依赖于正在设置的子流程,则在使用“user =”选项时这是必要的。
在有关 子流程环境 的主管文档之后:
所以也许可以尝试:
I believe this is caused by the fact that you didn't set the HOME and USER environment variables. This is necessary when using the "user=" option if your subprocess relies on those being set.
After supervisord documentation on Subprocess Environment:
So perhaps try: