mancelery.py 866 Bytes
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', 'storage.tasks.local_tasks',
                         'firewall.tasks.local_tasks'])
12 13 14

celery.conf.update(
    CELERY_QUEUES=(
15 16
        Queue(HOSTNAME + '.man', Exchange('manager', type='direct'),
              routing_key="manager"),
17 18 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
)