mancelery.py 1.13 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 12
                include=['vm.tasks.local_tasks',
                         'vm.tasks.local_periodic_tasks',
                         'storage.tasks.local_tasks',
13
                         'firewall.tasks.local_tasks'])
14 15 16

celery.conf.update(
    CELERY_QUEUES=(
17 18
        Queue(HOSTNAME + '.man', Exchange('manager', type='direct'),
              routing_key="manager"),
19 20 21 22 23 24 25 26 27
        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'}
        },
28 29 30 31 32
        'vm.periodic_tasks': {
            'task': 'vm.tasks.local_periodic_tasks.update_domain_states',
            'schedule': timedelta(seconds=10),
            'options': {'queue': 'localhost.man'}
        },
33 34
    }

35
)