【发布时间】:2016-05-06 17:25:31
【问题描述】:
我在 centos linux 服务器上使用 redis 安装了 celery。
我使用以下命令启动 celery worker:
celery multi start worker1 -A proj -Q lopri,lopri2 -l info --pidfile="$HOME/run/celery/%n.pid" --logfile="$HOME/log/celery/%n.log"
问题是几个小时后,worker 不再响应任务创建。我必须重新启动工作人员才能再次处理任务。
这是位于 /etc/default/celeryd 的 celery 设置文件:
# Names of nodes to start
# most people 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"
# alternatively, you can specify the number of nodes to start:
#CELERYD_NODES=10
# Absolute or relative path to the 'celery' command:
CELERY_BIN="/usr/local/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="proj"
# or fully qualified:
#CELERY_APP="proj.tasks:app"
#django settings
#export DJANGO_SETTINGS_MODULE="settings"
# Where to chdir at start.
CELERYD_CHDIR="/var/www/html/proj/"
# 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="ec2-user"
CELERYD_GROUP="ec2-user"
# If enabled pid and log directories will be created if missing,
# and owned by the userid/group configured.
CELERY_CREATE_DIRS=1
一个问题可能是关于正在发生的事情的线索是我必须从项目文件夹中运行“开始”命令,否则我会收到错误:
ImportError: 没有名为 proj 的模块
CELERYD_CHDIR 设置不应该解决这个问题吗?这是否意味着我的启动命令没有使用这个 celery 默认设置文件?
感谢您对此提供的任何启发。
【问题讨论】:
标签: python linux django celery daemon