add celery stuff
This commit is contained in:
parent
567d6007fe
commit
288abf1ad0
8
billard/tasks.py
Normal file
8
billard/tasks.py
Normal file
@ -0,0 +1,8 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
from celery import shared_task
|
||||
from . import models
|
||||
|
||||
|
||||
@shared_task
|
||||
def add(x, y):
|
||||
return x + y
|
@ -0,0 +1,7 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
# 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
|
||||
|
||||
__all__ = ['celery_app']
|
22
caromserver/celery.py
Normal file
22
caromserver/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', 'caromserver.settings')
|
||||
|
||||
app = Celery('caromserver')
|
||||
|
||||
# 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')
|
||||
|
||||
# Load task modules from all registered Django app configs.
|
||||
#app.autodiscover_tasks()
|
||||
|
||||
|
||||
@app.task(bind=True)
|
||||
def debug_task(self):
|
||||
print('Request: {0!r}'.format(self.request))
|
@ -138,6 +138,15 @@ LOGOUT_URL = 'logout'
|
||||
LOGIN_REDIRECT_URL = 'carom_index'
|
||||
LOGOUT_REDIRECT_URL = 'carom_index'
|
||||
|
||||
# CELERY STUFF
|
||||
BROKER_URL = 'redis://localhost:6379'
|
||||
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
|
||||
CELERY_ACCEPT_CONTENT = ['application/json']
|
||||
CELERY_TASK_SERIALIZER = 'json'
|
||||
CELERY_RESULT_SERIALIZER = 'json'
|
||||
CELERY_TIMEZONE = 'Europe/Berlin'
|
||||
|
||||
|
||||
STATIC_ROOT = "/srv/carom/carom-server/static/"
|
||||
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user