Shi*_*dla 8 django celery celery-task supervisord
我有一个django应用程序,它有芹菜功能,所以我能够成功运行芹菜如下
celery -A tasks worker --loglevel=info
Run Code Online (Sandbox Code Playgroud)
但作为一个众所周知的事实,我们需要将它作为守护进程运行,所以我在celery.conf
文件/etc/supervisor/conf.d/
夹中写了下面的文件
; ==================================
; 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
Run Code Online (Sandbox Code Playgroud)
但是当我试图更新主管时supervisorctl reread
,supervisorctl update
我正在收到消息supervisorctl status
celery FATAL Exited too quickly (process log may have details)
Run Code Online (Sandbox Code Playgroud)
所以我去了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
Run Code Online (Sandbox Code Playgroud)
那么为什么它抱怨, C_FORCE_ROOT
即使我们已将其设置为管理员conf文件中的环境变量?我在上面的conf文件中做错了什么?
您需要使用非超级用户帐户运行 celery,请从您的配置中删除以下行:
\n\nuser=root\nenvironment=C_FORCE_ROOT="yes"\nenvironment=HOME="/root",USER="root"\n
Run Code Online (Sandbox Code Playgroud)\n\n并将这些行添加到您的配置中,我假设您django
作为非超级用户和developers
用户组使用:
user=django\ngroup=developers\n
Run Code Online (Sandbox Code Playgroud)\n\n\n\n\n请注意,子进程将继承用于启动supervisord 的\n shell 的环境变量,但此处覆盖的变量\n 和program\xe2\x80\x99s 环境选项中的变量除外。参见监管文件。
\n
因此请注意,当您通过supervisor
配置文件更改环境变量时,更改将不会通过运行supervisorctl reread
和来应用supervisorctl reload
。您应该通过以下命令从一开始就运行主管:
supervisord -c /path/to/config/file.conf\n
Run Code Online (Sandbox Code Playgroud)\n
归档时间: |
|
查看次数: |
11175 次 |
最近记录: |