python - django 在生产环境中与主管一起启动 celery 守护进程

标签 python django celery supervisord

我在 /etc/supervisor/conf.d/myproject-celery.conf

中为主管创建了一个conf文件

我的配置文件如下所示:

[program:celery]
command=/var/www/html/project/venv/bin/python  /var/www/html/project/manage.py celeryd --loglevel=INFO
environment=PYTHONPATH=/var/www/html/project
directory=/var/www/html/project
user=www-data
numprocs=1
stdout_logfile=/var/log/celeryd.log
stderr_logfile=/var/log/celeryd.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 600
priority=998

在我的产品中,我想启动 celery 。为此我正在做

supervisord -c /etc/supervisor/conf.d/myproject-celery.conf

当我这样做时,它会说

Error: .ini file does not include supervisord section

这里有什么问题吗?

最佳答案

看起来您在配置文件中缺少 [supervisord] 部分,但这可能是因为您没有加载主conf文件

参见docs

您不应使用 -c 和 conf.d 文件启动 supervisord - 该文件夹中的文件通常会自动加载。通常,-c 是在您拥有在普通目录之外的其他位置创建的conf 时保留的。

如果您在没有 -c 的情况下启动supervisord,它应该加载您的/etc/supervisor/supervisor.conf 文件

你的conf文件应该是这样的:

; supervisor config file

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)

[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.

[include]
files = /etc/supervisor/conf.d/*.conf

如您所见,它会自动加载conf.d文件夹中的所有conf文件

关于python - django 在生产环境中与主管一起启动 celery 守护进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31656717/

相关文章:

python - 如何将图标添加到 ubuntu 应用程序

python - 使用变量作为具有预定义关键字的函数的关键字 (Python)

python - 如何递归地将返回列表的 Celery 任务链接到组中?

python - Celery Worker 在 docker 容器中运行时不选择任务

python - 在 Python 中,如何将 YAML 映射加载为 OrderedDicts?

python - 在Dockerfile中运行 “manage.py compilemessages”可得到 “django.db.utils.OperationalError: could not connect to server: No such file or directory”

python - 如何让buildout给virtualenv加蛋

Python 不能正确解释 UTF8

javascript - Flask + Celery + socketio 运行时错误 : Working outside of request context

python - shell脚本查找字符串并递归打印当前行和下一行