mancelery.py 1.7 KB
Newer Older
1
from celery import Celery
2
from datetime import timedelta
3
from kombu import Queue, Exchange
Guba Sándor committed
4
from os import getenv
5

Guba Sándor committed
6
HOSTNAME = "localhost"
7 8

celery = Celery('manager', backend='amqp',
Guba Sándor committed
9
                broker=getenv("AMQP_URI"),
10 11
                include=['vm.tasks.local_tasks',
                         'vm.tasks.local_periodic_tasks',
Bach Dániel committed
12
                         'vm.tasks.local_agent_tasks',
13
                         'storage.tasks.local_tasks',
14 15
                         'storage.tasks.periodic_tasks',
                         'firewall.tasks.local_tasks', ])
16 17

celery.conf.update(
Őry Máté committed
18
    CELERY_TASK_RESULT_EXPIRES=300,
19
    CELERY_QUEUES=(
20 21
        Queue(HOSTNAME + '.man', Exchange('manager', type='direct'),
              routing_key="manager"),
22 23 24 25 26 27 28 29 30
        Queue(HOSTNAME + '.monitor', Exchange('monitor', type='direct'),
              routing_key="monitor"),
    ),
    CELERYBEAT_SCHEDULE={
        'firewall.periodic_task': {
            'task': 'firewall.tasks.local_tasks.periodic_task',
            'schedule': timedelta(seconds=5),
            'options': {'queue': 'localhost.man'}
        },
31
        'vm.update_domain_states': {
32 33 34 35
            'task': 'vm.tasks.local_periodic_tasks.update_domain_states',
            'schedule': timedelta(seconds=10),
            'options': {'queue': 'localhost.man'}
        },
36 37 38 39 40
        'vm.garbage_collector': {
            'task': 'vm.tasks.local_periodic_tasks.garbage_collector',
            'schedule': timedelta(minutes=10),
            'options': {'queue': 'localhost.man'}
        },
41 42 43 44 45
        'storage.periodic_tasks': {
            'task': 'storage.tasks.periodic_tasks.garbage_collector',
            'schedule': timedelta(hours=1),
            'options': {'queue': 'localhost.man'}
        },
46 47
    }

48
)