celery integration & basic markup task

This commit is contained in:
2019-10-13 21:57:12 -07:00
parent 46f4080b93
commit 7803ae2fb1
6 changed files with 166 additions and 6 deletions

View File

@ -0,0 +1,5 @@
from __future__ import absolute_import, unicode_literals
from .celery import app as celery_app
__all__ = ('celery_app',)

15
procat2/celery.py Normal file
View File

@ -0,0 +1,15 @@
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'procat2.settings')
app = Celery('procat2')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
# @app.task(bind=True)
# def debug_task(self):
# print('Request: {0!r}'.format(self.request))

View File

@ -9,8 +9,15 @@ https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
from __future__ import absolute_import, unicode_literals
import os
# ^^^ The above is required if you want to import from the celery
# library. If you don't have this then `from celery.schedules import`
# becomes `proj.celery.schedules` in Python 2.x since it allows
# for relative imports by default.
from django.urls import reverse_lazy
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
@ -77,6 +84,12 @@ LOGGING = {
#'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
'propagate': True,
},
'markup': {
'handlers': ['console', 'file'],
'level': 'DEBUG',
#'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
'propagate': True,
},
'django': {
'handlers': ['console', 'file'],
#'level': 'DEBUG',
@ -101,6 +114,7 @@ INSTALLED_APPS = [
'django.contrib.staticfiles',
'django.contrib.sites',
'django_extensions',
'django_celery_results',
'account',
'lazysignup',
'webpack_loader',
@ -108,6 +122,7 @@ INSTALLED_APPS = [
'dashboard',
'products',
'quickinfo',
'markup',
]
MIDDLEWARE = [
@ -227,3 +242,13 @@ WEBPACK_LOADER = {
'IGNORE': [r'.+\.hot-update.js', r'.+\.map']
}
}
# allow large file uploads
# for example the markup tool receiving emails
DATA_UPLOAD_MAX_MEMORY_SIZE = FILE_UPLOAD_MAX_MEMORY_SIZE = 200 * 1024 * 1024 # 200MB
# celery settings
CELERY_BROKER_URL = 'amqp://guest:guest@localhost//'
CELERY_ACCEPT_CONTENT = ['json']
CELERY_RESULT_BACKEND = 'django-db'
CELERY_TASK_SERIALIZER = 'json'