add celery basics
This commit is contained in:
parent
78fc67ebdb
commit
e8c1e7006c
4 changed files with 24 additions and 1 deletions
11
src/c3nav/celery.py
Normal file
11
src/c3nav/celery.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
import os
|
||||
|
||||
from celery import Celery
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'c3nav.settings')
|
||||
|
||||
from django.conf import settings # noqa
|
||||
|
||||
app = Celery('c3nav')
|
||||
app.config_from_object('django.conf:settings')
|
||||
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
|
|
@ -101,6 +101,17 @@ if HAS_MEMCACHED:
|
|||
}
|
||||
SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
|
||||
|
||||
HAS_CELERY_BROKER = config.has_option('celery', 'broker')
|
||||
if HAS_CELERY_BROKER:
|
||||
BROKER_URL = config.get('celery', 'broker')
|
||||
CELERY_RESULT_BACKEND = config.get('celery', 'backend')
|
||||
CELERY_SEND_TASK_ERROR_EMAILS = bool(ADMINS)
|
||||
else:
|
||||
CELERY_ALWAYS_EAGER = True
|
||||
CELERY_TASK_SERIALIZER = 'json'
|
||||
CELERY_ACCEPT_CONTENT = ['json']
|
||||
CELERY_RESULT_SERIALIZER = 'json'
|
||||
|
||||
SESSION_COOKIE_DOMAIN = config.get('c3nav', 'cookie_domain', fallback=None)
|
||||
SESSION_COOKIE_SECURE = config.getboolean('c3nav', 'session_cookie_secure', fallback=False)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue