# coding=utf-8
from kombu import Queue
from kombu import Exchange

from celery.schedules import crontab

BROKER_URL = 'redis://127.0.0.1:6379'  # 指定 Broker

CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379/0'  # 指定 Backend

CELERY_CREATE_MISSING_QUEUES = True  # 某个程序中出现的队列，在broker中不存在，则立刻创建它

CELERY_TIMEZONE = 'Asia/Shanghai'  # 指定时区，默认是 UTC

CELERYD_CONCURRENCY = 2  # 并发worker数

CELERY_ENABLE_UTC = False

CELERYD_FORCE_EXECV = True  # 强制退出

CELERY_TASK_SERIALIZER = 'json'  # 任务序列化和反序列化

CELERY_RESULT_SERIALIZER = 'json'  # 读取任务结果一般性能要求不高，所以使用了可读性更好的JSON

CELERY_IGNORE_RESULT = True  # 忽略任务结果

# CELERY_TASK_RESULT_EXPIRES = 60 * 60 * 1  # 任务结果过期时间

CELERY_IMPORTS = (  # 指定导入的任务模块
    'webspider.tasks.actor.lg_data',
    'webspider.tasks.actor.lg_jobs_count',
    'webspider.tasks.actor.keyword_statistic',
)

CELERY_TASK_PUBLISH_RETRY = False  # 重试

CELERYBEAT_SCHEDULE = {
    'crawl_lg_jobs_count_task': {
        'task': 'webspider.tasks.actor.lg_jobs_count.crawl_lg_jobs_count_task',
        'schedule': crontab(hour='01', minute='01', day_of_week='2, 5'),
    },
    'crawl_lg_data_task': {
        'task': 'webspider.tasks.actor.lg_data.crawl_lg_data_task',
        'schedule': crontab(hour='01', minute='01', day_of_month='1'),
    },
    'update_keyword_statistic': {
        'task': 'webspider.tasks.actor.keyword_statistic.update_keywords_statistic_task',
        'schedule': crontab(hour='01', minute='01', day_of_week='1, 4'),
    },
}

default_exchange = Exchange('default', type='direct')
lg_exchange = Exchange('lg', type='direct')

CELERY_QUEUES = (
    Queue(name='default', exchange=default_exchange, routing_key='default'),
    Queue(name='lg_data', exchange=lg_exchange, routing_key='for_lg_data'),
    Queue(name='lg_jobs_data', exchange=lg_exchange, routing_key='for_lg_jobs_data'),
    Queue(name='lg_jobs_count', exchange=lg_exchange, routing_key='for_lg_jobs_count'),
)

CELERY_ROUTES = {
    'webspider.tasks.actor.lg_data.crawl_lg_job_data_task': {'exchange': 'lg',
                                                             'routing_key': 'for_lg_jobs_data'},
    'webspider.tasks.actor.lg_jobs_count.*': {'exchange': 'lg', 'routing_key': 'for_lg_jobs_count'},
    'webspider.tasks.actor.lg_data.*': {'exchange': 'lg', 'routing_key': 'for_lg_data'},
    'webspider.tasks.actor.keyword_statistic.*': {'exchange': 'default', 'routing_key': 'default'}
}

407d44c0708ef11b4d11b53c66bedfacce8c9d5f
<mask token>

<mask token>
BROKER_URL = 'redis://127.0.0.1:6379'
CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379/0'
CELERY_CREATE_MISSING_QUEUES = True
CELERY_TIMEZONE = 'Asia/Shanghai'
CELERYD_CONCURRENCY = 2
CELERY_ENABLE_UTC = False
CELERYD_FORCE_EXECV = True
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_IGNORE_RESULT = True
CELERY_IMPORTS = ('webspider.tasks.actor.lg_data',
    'webspider.tasks.actor.lg_jobs_count',
    'webspider.tasks.actor.keyword_statistic')
CELERY_TASK_PUBLISH_RETRY = False
CELERYBEAT_SCHEDULE = {'crawl_lg_jobs_count_task': {'task':
    'webspider.tasks.actor.lg_jobs_count.crawl_lg_jobs_count_task',
    'schedule': crontab(hour='01', minute='01', day_of_week='2, 5')},
    'crawl_lg_data_task': {'task':
    'webspider.tasks.actor.lg_data.crawl_lg_data_task', 'schedule': crontab
    (hour='01', minute='01', day_of_month='1')}, 'update_keyword_statistic':
    {'task':
    'webspider.tasks.actor.keyword_statistic.update_keywords_statistic_task',
    'schedule': crontab(hour='01', minute='01', day_of_week='1, 4')}}
default_exchange = Exchange('default', type='direct')
lg_exchange = Exchange('lg', type='direct')
CELERY_QUEUES = Queue(name='default', exchange=default_exchange,
    routing_key='default'), Queue(name='lg_data', exchange=lg_exchange,
    routing_key='for_lg_data'), Queue(name='lg_jobs_data', exchange=
    lg_exchange, routing_key='for_lg_jobs_data'), Queue(name=
    'lg_jobs_count', exchange=lg_exchange, routing_key='for_lg_jobs_count')
CELERY_ROUTES = {'webspider.tasks.actor.lg_data.crawl_lg_job_data_task': {
    'exchange': 'lg', 'routing_key': 'for_lg_jobs_data'},
    'webspider.tasks.actor.lg_jobs_count.*': {'exchange': 'lg',
    'routing_key': 'for_lg_jobs_count'}, 'webspider.tasks.actor.lg_data.*':
    {'exchange': 'lg', 'routing_key': 'for_lg_data'},
    'webspider.tasks.actor.keyword_statistic.*': {'exchange': 'default',
    'routing_key': 'default'}}

from kombu import Queue
from kombu import Exchange
from celery.schedules import crontab
BROKER_URL = 'redis://127.0.0.1:6379'
CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379/0'
CELERY_CREATE_MISSING_QUEUES = True
CELERY_TIMEZONE = 'Asia/Shanghai'
CELERYD_CONCURRENCY = 2
CELERY_ENABLE_UTC = False
CELERYD_FORCE_EXECV = True
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_IGNORE_RESULT = True
CELERY_IMPORTS = ('webspider.tasks.actor.lg_data',
    'webspider.tasks.actor.lg_jobs_count',
    'webspider.tasks.actor.keyword_statistic')
CELERY_TASK_PUBLISH_RETRY = False
CELERYBEAT_SCHEDULE = {'crawl_lg_jobs_count_task': {'task':
    'webspider.tasks.actor.lg_jobs_count.crawl_lg_jobs_count_task',
    'schedule': crontab(hour='01', minute='01', day_of_week='2, 5')},
    'crawl_lg_data_task': {'task':
    'webspider.tasks.actor.lg_data.crawl_lg_data_task', 'schedule': crontab
    (hour='01', minute='01', day_of_month='1')}, 'update_keyword_statistic':
    {'task':
    'webspider.tasks.actor.keyword_statistic.update_keywords_statistic_task',
    'schedule': crontab(hour='01', minute='01', day_of_week='1, 4')}}
default_exchange = Exchange('default', type='direct')
lg_exchange = Exchange('lg', type='direct')
CELERY_QUEUES = Queue(name='default', exchange=default_exchange,
    routing_key='default'), Queue(name='lg_data', exchange=lg_exchange,
    routing_key='for_lg_data'), Queue(name='lg_jobs_data', exchange=
    lg_exchange, routing_key='for_lg_jobs_data'), Queue(name=
    'lg_jobs_count', exchange=lg_exchange, routing_key='for_lg_jobs_count')
CELERY_ROUTES = {'webspider.tasks.actor.lg_data.crawl_lg_job_data_task': {
    'exchange': 'lg', 'routing_key': 'for_lg_jobs_data'},
    'webspider.tasks.actor.lg_jobs_count.*': {'exchange': 'lg',
    'routing_key': 'for_lg_jobs_count'}, 'webspider.tasks.actor.lg_data.*':
    {'exchange': 'lg', 'routing_key': 'for_lg_data'},
    'webspider.tasks.actor.keyword_statistic.*': {'exchange': 'default',
    'routing_key': 'default'}}

# coding=utf-8
from kombu import Queue
from kombu import Exchange

from celery.schedules import crontab

BROKER_URL = 'redis://127.0.0.1:6379'  # 指定 Broker

CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379/0'  # 指定 Backend

CELERY_CREATE_MISSING_QUEUES = True  # 某个程序中出现的队列，在broker中不存在，则立刻创建它

CELERY_TIMEZONE = 'Asia/Shanghai'  # 指定时区，默认是 UTC

CELERYD_CONCURRENCY = 2  # 并发worker数

CELERY_ENABLE_UTC = False

CELERYD_FORCE_EXECV = True  # 强制退出

CELERY_TASK_SERIALIZER = 'json'  # 任务序列化和反序列化

CELERY_RESULT_SERIALIZER = 'json'  # 读取任务结果一般性能要求不高，所以使用了可读性更好的JSON

CELERY_IGNORE_RESULT = True  # 忽略任务结果

# CELERY_TASK_RESULT_EXPIRES = 60 * 60 * 1  # 任务结果过期时间

CELERY_IMPORTS = (  # 指定导入的任务模块
    'webspider.tasks.actor.lg_data',
    'webspider.tasks.actor.lg_jobs_count',
    'webspider.tasks.actor.keyword_statistic',
)

CELERY_TASK_PUBLISH_RETRY = False  # 重试

CELERYBEAT_SCHEDULE = {
    'crawl_lg_jobs_count_task': {
        'task': 'webspider.tasks.actor.lg_jobs_count.crawl_lg_jobs_count_task',
        'schedule': crontab(hour='01', minute='01', day_of_week='2, 5'),
    },
    'crawl_lg_data_task': {
        'task': 'webspider.tasks.actor.lg_data.crawl_lg_data_task',
        'schedule': crontab(hour='01', minute='01', day_of_month='1'),
    },
    'update_keyword_statistic': {
        'task': 'webspider.tasks.actor.keyword_statistic.update_keywords_statistic_task',
        'schedule': crontab(hour='01', minute='01', day_of_week='1, 4'),
    },
}

default_exchange = Exchange('default', type='direct')
lg_exchange = Exchange('lg', type='direct')

CELERY_QUEUES = (
    Queue(name='default', exchange=default_exchange, routing_key='default'),
    Queue(name='lg_data', exchange=lg_exchange, routing_key='for_lg_data'),
    Queue(name='lg_jobs_data', exchange=lg_exchange, routing_key='for_lg_jobs_data'),
    Queue(name='lg_jobs_count', exchange=lg_exchange, routing_key='for_lg_jobs_count'),
)

CELERY_ROUTES = {
    'webspider.tasks.actor.lg_data.crawl_lg_job_data_task': {'exchange': 'lg',
                                                             'routing_key': 'for_lg_jobs_data'},
    'webspider.tasks.actor.lg_jobs_count.*': {'exchange': 'lg', 'routing_key': 'for_lg_jobs_count'},
    'webspider.tasks.actor.lg_data.*': {'exchange': 'lg', 'routing_key': 'for_lg_data'},
    'webspider.tasks.actor.keyword_statistic.*': {'exchange': 'default', 'routing_key': 'default'}
}
