【发布时间】:2014-08-30 06:49:36
【问题描述】:
我有一个 django 应用程序,它具有 celery 功能,所以我可以像下面那样成功运行 celery
celery -A tasks worker --loglevel=info
但众所周知,我们需要将其作为守护进程运行,因此我在/etc/supervisor/conf.d/ 文件夹中编写了以下celery.conf 文件
; ==================================
; celery worker supervisor example
; ==================================
[program:celery]
; Set full path to celery program if using virtualenv
command=/root/Envs/proj/bin/celery -A app.tasks worker --loglevel=info
user=root
environment=C_FORCE_ROOT="yes"
environment=HOME="/root",USER="root"
directory=/root/apps/proj/structure
numprocs=1
stdout_logfile=/var/log/celery/worker.log
stderr_logfile=/var/log/celery/worker.log
autostart=true
autorestart=true
startsecs=10
; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 600
; When resorting to send SIGKILL to the program to terminate it
; send SIGKILL to its whole process group instead,
; taking care of its children as well.
killasgroup=true
; if rabbitmq is supervised, set its priority higher
; so it starts first
priority=998
但是当我尝试像 supervisorctl reread 和 supervisorctl update 这样更新主管时,我收到了来自 supervisorctl status 的消息
celery FATAL Exited too quickly (process log may have details)
所以我去了worker.log文件并看到如下错误消息
Running a worker with superuser privileges when the
worker accepts messages serialized with pickle is a very bad idea!
If you really want to continue then you have to set the C_FORCE_ROOT
environment variable (but please think about this before you do).
User information: uid=0 euid=0 gid=0 egid=0
那么为什么它抱怨C_FORCE_ROOT,即使我们已经将它设置为主管配置文件中的环境变量?我在上面的 conf 文件中做错了什么?
【问题讨论】:
-
不要以 root 身份运行——它不应该是必要的。 (你是否在 Django 中使用它——以与那里相同的用户身份运行。)
-
是的,当我删除
environment=HOME="/root",USER="root"行时,它工作正常 -
我在使用 AWS Elasticbeanstalk 时遇到了这个问题,使用 user=ec2-user 为我解决了这个问题
标签: django celery supervisord celery-task