为什么芹菜不在特定时间运行周期性任务

时间:2018-05-26 13:23:04

标签: python python-3.x celery

Celery在特定时间没有运行定期任务,我的芹菜配置我的cron任务send_email_notifications

from celery import Celery
from celery.schedules import crontab

class Config:
    timezone = 'Europe/Minsk'
    enable_utc = True

    task_always_eager = False
    broker_url = 'amqp://%s:%s@%s:%s//' % (RABBITMQ_USERNAME, RABBITMQ_PASSWORD, RABBITMQ_HOST, RABBITMQ_PORT)
    result_expires = 3600
    worker_prefetch_multiplier = 1
    worker_max_memory_per_child = 250000  # 250MB

    imports = (
        'app.jobs.clients_job',
    )
    task_routes = {
        'app.jobs.clients_job.send_email': {'queue': 'clients'},
        # Periodic tasks
        'app.jobs.clients_job.send_email_notifications': {'queue': 'periodic_api'},
    }

    beat_schedule = {
        'send-email-notifications': {
            'task': 'app.jobs.clients_job.send_email_notifications',
            'schedule': crontab(hour=16, minute=4),
            'args': (),
        },
    }
    worker_hijack_root_logger = False
    accept_content = ['json']


celery = Celery()
celery.config_from_object(Config)

app.jobs.clients_job

@celery.task
def send_email_notifications():
    t = datetime.date.today()
    logger.info('started')
    logger.info(t)

我正在经营芹菜工作者:

`$ celery worker -c 1 -n prtperiodicapi -l INFO -A config.celery_config -B -E -Q periodic_api -s /tmp/api_celerybeat_schedule_periodic`

但为什么任务没有在16:04运行?

celery == 4.1.1
python 3.5.2

服务器日期时间

$ date

Sat May 26 16:02:48 +03 2018

ALSO: 空crontab(),定期运行任务

更新: 与工人分开运行celery beat没有帮助

celery beat v4.1.1 (latentcall) is starting.
__    -    ... __   -        _
LocalTime -> 2018-05-26 16:58:11
Configuration ->
    . broker -> amqp://guest:**@localhost:5672//
    . loader -> celery.loaders.default.Loader
    . scheduler -> celery.beat.PersistentScheduler
    . db -> celerybeat-schedule
    . logfile -> [stderr]@%WARNING
    . maxinterval -> 5.00 minutes (300s)

0 个答案:

没有答案