我正在尝试在 生产环境 中经营芹菜和芹菜 . 在我目前的django应用程序中,我能够使用命令“celery -A Gorgon worker”和“celery -A Gorgon beat -l debug --max-interval = 10”进行测试和运行 . 另外,我通过virtualenv运行它 . 另外,我使用redis作为任务经纪人 .
整个应用程序在gunicorn服务器上运行 . 但是,当我尝试守护进程时,它失败并出现111连接错误 .
我已将https://github.com/celery/celery/tree/3.0/extra/generic-init.d中所需的脚本添加到目录/etc/init.d中
至于/ etc / defaults中的脚本,它们看起来像这样:
我的芹菜脚本如下
# Names of nodes to start
# most will only start one node:
CELERYD_NODES="worker1"
# but you can also start multiple and configure settings
# for each in CELERYD_OPTS (see `celery multi --help` for examples).
#CELERYD_NODES="worker1 worker2 worker3"
# Absolute or relative path to the 'celery' command:
#CELERY_BIN="/usr/local/bin/celery"
CELERY_BIN="/home/ubuntu/sites/virtualenv/bin/celery"
# App instance to use
# comment out this line if you don't use an app
CELERY_APP="Gorgon"
# or fully qualified:
#CELERY_APP="proj.tasks:app"
# Where to chdir at start.
CELERYD_CHDIR="/home/ubuntu/sites/source"
# Extra command-line arguments to the worker
CELERYD_OPTS="--time-limit=300 --concurrency=8"
# %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.
# You need to create this user manually (or you can choose
# a user/group combination that already exists, e.g. nobody).
#CELERYD_USER="celery"
#CELERYD_GROUP="celery"
# If enabled pid and log directories will be created if missing,
# and owned by the userid/group configured.
CELERY_CREATE_DIRS=1
我的celerybeat脚本是
# Absolute or relative path to the 'celery' command:
CELERY_BIN="/home/ubuntu/sites/virtualenv/bin/celery"
#CELERY_BIN="/virtualenvs/def/bin/celery"
# App instance to use
# comment out this line if you don't use an app
CELERY_APP="Gorgon"
# or fully qualified:
#CELERY_APP="proj.tasks:app"
# Where to chdir at start.
CELERYBEAT_CHDIR="/home/ubuntu/sites/source"
# Extra arguments to celerybeat
#CELERYBEAT_OPTS="--schedule=/var/run/celery/celerybeat-schedule"
如何使用我在/ home / ubuntu / sites / virtualenv中的当前虚拟环境将我的芹菜设置作为守护进程运行
1 回答
要在守护进程中运行celery,您可以使用主管 . 这个链接可能会帮助您了解如何在守护进程模式下运行芹菜 . http://www.hiddentao.com/archives/2012/01/27/processing-long-running-django-tasks-using-celery-rabbitmq-supervisord-monit/