Added celery files
This commit is contained in:
parent
90f01c277b
commit
d8592fc6d8
4 changed files with 38 additions and 0 deletions
|
@ -0,0 +1,5 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
# This will make sure the app is always imported when
|
||||
# Django starts so that shared_task will use this app.
|
||||
from .celery import app as celery_app
|
22
dynamicweb/celery.py
Normal file
22
dynamicweb/celery.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from __future__ import absolute_import, unicode_literals
|
||||
import os
|
||||
from celery import Celery
|
||||
|
||||
# set the default Django settings module for the 'celery' program.
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dynamicweb.settings')
|
||||
|
||||
app = Celery('dynamicweb')
|
||||
|
||||
# Using a string here means the worker don't have to serialize
|
||||
# the configuration object to child processes.
|
||||
# - namespace='CELERY' means all celery-related configuration keys
|
||||
# should have a `CELERY_` prefix.
|
||||
app.config_from_object('django.conf:settings', namespace='CELERY')
|
||||
|
||||
# Load task modules from all registered Django app configs.
|
||||
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
|
||||
|
||||
|
||||
@app.task(bind=True)
|
||||
def debug_task(self):
|
||||
print('Request: {0!r}'.format(self.request))
|
|
@ -521,6 +521,15 @@ GOOGLE_ANALYTICS_PROPERTY_IDS = {
|
|||
'dynamicweb-staging.ungleich.ch': 'staging'
|
||||
}
|
||||
|
||||
# CELERY Settings
|
||||
#BROKER_URL = 'redis://localhost:6379'
|
||||
BROKER_URL = 'redis+socket:///var/run/redis/redis.sock'
|
||||
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
|
||||
CELERY_ACCEPT_CONTENT = ['application/json']
|
||||
CELERY_TASK_SERIALIZER = 'json'
|
||||
CELERY_RESULT_SERIALIZER = 'json'
|
||||
CELERY_TIMEZONE = 'Europe/Zurich'
|
||||
|
||||
ENABLE_DEBUG_LOGGING = bool_env('ENABLE_DEBUG_LOGGING')
|
||||
|
||||
if ENABLE_DEBUG_LOGGING:
|
||||
|
|
|
@ -86,3 +86,5 @@ git+https://github.com/ungleich/python-oca.git#egg=python-oca
|
|||
djangorestframework
|
||||
flake8==3.3.0
|
||||
python-memcached==1.58
|
||||
celery==4.0.2
|
||||
redis==2.10.5
|
||||
|
|
Loading…
Reference in a new issue