diff --git a/mayan/celery.py b/mayan/celery.py index 4c3995bc8b..ca8fc9cdad 100644 --- a/mayan/celery.py +++ b/mayan/celery.py @@ -2,12 +2,13 @@ from __future__ import absolute_import, unicode_literals import os -from celery import Celery from django.conf import settings +from .runtime import celery_class + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mayan.settings.production') -app = Celery('mayan') +app = celery_class('mayan') app.config_from_object('django.conf:settings') app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) diff --git a/mayan/conf.py b/mayan/conf.py new file mode 100644 index 0000000000..5ddcfc8185 --- /dev/null +++ b/mayan/conf.py @@ -0,0 +1,18 @@ +""" +This module should be called settings.py but is named conf.py to avoid a +class with the mayan/settings/* module +""" + +from __future__ import unicode_literals + +from django.utils.translation import ugettext_lazy as _ + +from smart_settings import Namespace + +namespace = Namespace(name='mayan', label=_('Mayan')) + +setting_celery_class = namespace.add_setting( + help_text=_('The class used to instanciate the main Celery app.'), + global_name='MAYAN_CELERY_CLASS', + default='celery.Celery' +) diff --git a/mayan/runtime.py b/mayan/runtime.py new file mode 100644 index 0000000000..16a382b63e --- /dev/null +++ b/mayan/runtime.py @@ -0,0 +1,5 @@ +from django.utils.module_loading import import_string + +from .conf import setting_celery_class + +celery_class = import_string(setting_celery_class.value)