我无法在服务器上设置Celery作为守护进程(django 1.6.11,celery 3.1,Ubuntu 14.04) 尝试了很多选项,任何人都可以完全设置工作配置来运行芹菜作为守护进程吗?
我对官方文档http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#generic-init-scripts感到非常失望 - 这些都不起作用,没有完整的分步教程。 youtube上有关如何设置守护程序的零(!!!)视频。
现在我能够通过芹菜工人--A引擎-l info -E来简单地运行芹菜 来自django的任务已成功执行。
我做过配置:
/ etc / defaults / celery
# Name of nodes to start
# here we have a single node
CELERYD_NODES="w1"
# or we could have three nodes:
#CELERYD_NODES="w1 w2 w3"
# Absolute path to "manage.py"
CELERY_BIN="/var/www/engine/manage.py"
# How to call manage.py
CELERYD_MULTI="celery multi"
# Extra command-line arguments to the worker
CELERYD_OPTS="--time-limit=300 --concurrency=2"
# %N will be replaced with the first part of the nodename.
CELERYD_LOG_FILE="/var/log/celery/%N.log"
CELERYD_PID_FILE="/var/run/celery/%N.pid"
# Workers should run as an unprivileged user.
CELERYD_USER="root"
CELERYD_GROUP="root"
/etc/init.d/celeryd
来自https://github.com/celery/celery/blob/3.1/extra/generic-init.d/celeryd而没有变更
现在,当我去控制台并运行时: cd /etc/init.d 芹菜多开始w1
我看到输出:
celery multi v3.1.11 (Cipater)
> Starting nodes...
> w1@engine: OK
所以,没有错误!任务没有被调用,我无法弄清楚什么是错的。
答案 0 :(得分:2)
我建议使用Supervisor。它比init脚本更好,因为您可以在一台服务器上为不同的项目运行多个Celery实例。您可以在Celery repo中找到Supervisor的示例配置,也可以从我的项目中找到完整的示例:
# /etc/supervisor/conf.d/celery.conf
[program:celery]
command=/home/newspos/.virtualenvs/newspos/bin/celery worker -A newspos --loglevel=INFO
user=newspos
environment=DJANGO_SETTINGS_MODULE="newspos.settings"
directory=/home/newspos/projects/newspos/
autostart=true
autorestart=true
stopwaitsecs = 600
killasgroup=true
startsecs=10
stdout_logfile=/var/log/celery/newspos-celeryd.log
stderr_logfile=/var/log/celery/newspos-celeryd.log