summaryrefslogtreecommitdiffstats
path: root/tools/pharos-dashboard/pharos_dashboard
diff options
context:
space:
mode:
Diffstat (limited to 'tools/pharos-dashboard/pharos_dashboard')
-rw-r--r--tools/pharos-dashboard/pharos_dashboard/__init__.py3
-rw-r--r--tools/pharos-dashboard/pharos_dashboard/celery.py20
-rw-r--r--tools/pharos-dashboard/pharos_dashboard/settings.py15
3 files changed, 33 insertions, 5 deletions
diff --git a/tools/pharos-dashboard/pharos_dashboard/__init__.py b/tools/pharos-dashboard/pharos_dashboard/__init__.py
index e69de29b..b6fc8176 100644
--- a/tools/pharos-dashboard/pharos_dashboard/__init__.py
+++ b/tools/pharos-dashboard/pharos_dashboard/__init__.py
@@ -0,0 +1,3 @@
+# 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 # noqa
diff --git a/tools/pharos-dashboard/pharos_dashboard/celery.py b/tools/pharos-dashboard/pharos_dashboard/celery.py
new file mode 100644
index 00000000..4cf6a7af
--- /dev/null
+++ b/tools/pharos-dashboard/pharos_dashboard/celery.py
@@ -0,0 +1,20 @@
+import os
+
+from celery import Celery
+
+# set the default Django settings module for the 'celery' program.
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pharos_dashboard.settings')
+
+from django.conf import settings # noqa
+
+app = Celery('pharos_dashboard')
+
+# Using a string here means the worker will not have to
+# pickle the object when using Windows.
+app.config_from_object('django.conf:settings')
+app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
+
+
+@app.task(bind=True)
+def debug_task(self):
+ print('Request: {0!r}'.format(self.request)) \ No newline at end of file
diff --git a/tools/pharos-dashboard/pharos_dashboard/settings.py b/tools/pharos-dashboard/pharos_dashboard/settings.py
index b6e98991..77175016 100644
--- a/tools/pharos-dashboard/pharos_dashboard/settings.py
+++ b/tools/pharos-dashboard/pharos_dashboard/settings.py
@@ -15,7 +15,6 @@ import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
@@ -27,7 +26,6 @@ DEBUG = True
ALLOWED_HOSTS = []
-
# Application definition
INSTALLED_APPS = [
@@ -43,6 +41,8 @@ INSTALLED_APPS = [
'django.contrib.staticfiles',
'django.contrib.humanize',
'bootstrap3',
+ 'djcelery',
+ 'kombu.transport.django',
]
MIDDLEWARE = [
@@ -77,7 +77,6 @@ TEMPLATES = [
WSGI_APPLICATION = 'pharos_dashboard.wsgi.application'
-
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
@@ -92,7 +91,6 @@ DATABASES = {
}
}
-
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
@@ -124,7 +122,6 @@ USE_L10N = True
USE_TZ = True
-
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
@@ -139,3 +136,11 @@ BOOTSTRAP3 = {
}
LOGIN_REDIRECT_URL = '/'
+
+import djcelery
+
+djcelery.setup_loader()
+# django broker, NOT SAFE FOR PRODUCTION
+BROKER_URL = 'django://'
+CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
+