2018-04-02 05:19:31 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
from celery import Celery
|
2022-12-22 05:58:29 +00:00
|
|
|
from kombu import Exchange, Queue
|
2018-04-02 05:19:31 +00:00
|
|
|
|
|
|
|
# set the default Django settings module for the 'celery' program.
|
|
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'jumpserver.settings')
|
2019-03-22 07:18:47 +00:00
|
|
|
from jumpserver import settings
|
2022-12-22 05:58:29 +00:00
|
|
|
from .heatbeat import *
|
|
|
|
|
2019-03-22 07:18:47 +00:00
|
|
|
# from django.conf import settings
|
2018-04-02 05:19:31 +00:00
|
|
|
|
|
|
|
app = Celery('jumpserver')
|
|
|
|
|
2019-03-22 07:18:47 +00:00
|
|
|
configs = {k: v for k, v in settings.__dict__.items() if k.startswith('CELERY')}
|
2018-04-02 05:19:31 +00:00
|
|
|
# Using a string here means the worker will not have to
|
|
|
|
# pickle the object when using Windows.
|
2019-03-22 07:18:47 +00:00
|
|
|
# app.config_from_object('django.conf:settings', namespace='CELERY')
|
2019-08-21 12:27:21 +00:00
|
|
|
configs["CELERY_QUEUES"] = [
|
|
|
|
Queue("celery", Exchange("celery"), routing_key="celery"),
|
|
|
|
Queue("ansible", Exchange("ansible"), routing_key="ansible"),
|
|
|
|
]
|
|
|
|
|
2019-03-22 07:18:47 +00:00
|
|
|
app.namespace = 'CELERY'
|
|
|
|
app.conf.update(configs)
|
2018-04-02 05:19:31 +00:00
|
|
|
app.autodiscover_tasks(lambda: [app_config.split('.')[0] for app_config in settings.INSTALLED_APPS])
|