我在我的Celery
服务器上寻找配置FreeBSD
,我根据日志文件得到了一些问题。
我的配置:
我的Celery配置文件:
我在/ etc / default / celeryd_app1中:
# Names of nodes to start
CELERYD_NODES="worker"
# Absolute or relative path to the 'celery' command:
CELERY_BIN="/usr/local/www/app1/venv/bin/celery"
# App instance to use
CELERY_APP="main"
# Where to chdir at start.
CELERYD_CHDIR="/usr/local/www/app1/src/"
# Extra command-line arguments to the worker
CELERYD_OPTS="--time-limit=300 --concurrency=8"
# Set logging level to DEBUG
#CELERYD_LOG_LEVEL="DEBUG"
# %n will be replaced with the first part of the nodename.
CELERYD_LOG_FILE="/var/log/celery/app1/%n%I.log"
CELERYD_PID_FILE="/var/run/celery/app1/%n.pid"
# Workers should run as an unprivileged user.
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
我对celeryd_app2有完全相同的文件
使用Celery设置的Django设置文件:
CELERY_BROKER_URL = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_IGNORE_RESULT = False
CELERY_TASK_TRACK_STARTED = True
# Add a one-minute timeout to all Celery tasks.
CELERYD_TASK_SOFT_TIME_LIMIT = 60
两个设置都具有相同的redis'端口。
我的问题:
当我为app1执行celery任务时,我在app2日志文件中找到来自此任务的日志,问题如下:
Received unregistered task of type 'app1.task.my_task_for_app1'
...
KeyError: 'app1.task.my_task_for_app1'
我的Celery配置文件中存在问题?我必须设置不同的redis端口?如果是的话,我该怎么做?
非常感谢你
我想问题在于你在两个应用程序中使用相同的Redis数据库:
CELERY_BROKER_URL = 'redis://localhost:6379'
查看the guide使用Redis作为经纪人。只需更改每个应用程序的数据库,例如
CELERY_BROKER_URL = 'redis://localhost:6379/0'
和
CELERY_BROKER_URL = 'redis://localhost:6379/1'