我正在尝试在生产中运行 celery 和 celerybeat。在我当前的 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 中的当前虚拟环境让我的 celery 设置作为守护进程运行