我有一些用celery运行的定期任务(由supervisord守护进程)运行,但是在尝试为用户设置主目录中的目录后,我为supervisor的进程设置了一个权限被拒绝"错误.在查看正在运行的celery任务中的 os.environ 字典后,我注意到 USER var设置为"root",而不是我在supervised中设置的用户芹菜的配置.
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.
这是我的/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可能是什么原因造成的?任何帮助将不胜感激!
What could be causing this? Any help would be super appreciated!
推荐答案我相信这是由于您没有设置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.
在子流程环境的受监管文档之后:
主管运行子进程时,supervisor不会执行任何外壳程序,因此不会更改环境变量(例如USER,PATH,HOME,SHELL,LOGNAME等)的默认值,也不会对其进行重新分配
No shell is executed by supervisord when it runs a subprocess, so environment variables such as USER, PATH, HOME, SHELL, LOGNAME, etc. are not changed from their defaults or otherwise reassigned
所以也许尝试:
environment=USER=<USER>,HOME=/home/<USER>,PYTHONPATH=/home/<USER>/apps/sync更多推荐
主管的芹菜用户不正确
发布评论