我正在尝试在芹菜中守护我的任务,我已经在没有守护程序的情况下进行了测试,它运行良好。
但是我不能像教程所说的那样守护程序(http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#daemonizing)我有我的文件:
solr_desa.py
from celery import Celery
celery = Celery('solrdesa')
celery.config_from_object('celeryconfig')
@celery.task(name = "doSomething")
def doSomething():
return 6
celeryconfig.py
from celery.schedules import crontab
BROKER_URL = '127.0.0.1'
BROKER_PORT = 5673
CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6969/0'
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TIMEZONE = 'America/Santiago'
CELERY_IMPORTS = ('solr_desa', )
CELERYBEAT_SCHEDULE = {
'solr_schedule': {
'task': 'doSomething',
'schedule': crontab(minute=9, hour=12)
},
}
而且/etc/default/celeryd
CELERY_NODES="w1"
CELERYD_CHDIR="/opt/latam/script/solr"
CELERYD_OPTS="--time-limit=300 --concurrency=8"
CELERY_CONFIG_MODULE="celeryconfig"
CELERYD_LOG_FILE="/var/log/celery/%n.log"
CELERYD_PID_FILE="/var/run/celery/%n.pid"
我在 https://github.com/celery/celery/blob/3.0/extra/generic-init.d/celeryd 中使用默认的芹菜执行,但任务只是排队,但看起来没有工人:(
我的配置错误在哪里?:(
您的经纪人 URL 是错误的,它应该是这样的
BROKER_URL : transport://userid:password@hostname:port/virtual_host
#example
BROKER_URL = "amqp://{username}:{password}@{host}:{port}//"
阅读此处了解更多详情