diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-03-15 14:32:47 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-17 13:21:27 +0200 |
commit | fd0cad6737e1b10ca8574428e1884e8c4755146e (patch) | |
tree | 61c86fc94eb6bb603ac736396a061a526d625cc2 | |
parent | 20813662d8d91b91dda46d67acbb5e869eb4e064 (diff) | |
download | Ishtar-fd0cad6737e1b10ca8574428e1884e8c4755146e.tar.bz2 Ishtar-fd0cad6737e1b10ca8574428e1884e8c4755146e.zip |
Celery configuration
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | example_project/__init__.py.base.sample (renamed from example_project/__init__.py) | 0 | ||||
-rw-r--r-- | example_project/__init__.py.celery.sample | 15 | ||||
-rw-r--r-- | example_project/celery.py.sample | 18 | ||||
-rw-r--r-- | example_project/settings.py | 4 | ||||
-rwxr-xr-x | install/ishtar-prepare-instance | 6 | ||||
-rw-r--r-- | requirements.txt | 3 |
7 files changed, 45 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore index 581c2698f..04e2482f5 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,8 @@ local_settings.py fabfile.py example_project/media example_project/static +example_project/celery.py +example_project/__init__.py docs/*/build Makefile oook_replace diff --git a/example_project/__init__.py b/example_project/__init__.py.base.sample index c6adb7559..c6adb7559 100644 --- a/example_project/__init__.py +++ b/example_project/__init__.py.base.sample diff --git a/example_project/__init__.py.celery.sample b/example_project/__init__.py.celery.sample new file mode 100644 index 000000000..ebae6a3c3 --- /dev/null +++ b/example_project/__init__.py.celery.sample @@ -0,0 +1,15 @@ +# force the retranslation of generated strings and external module +from django.utils.translation import ugettext_lazy as _ + +from .celery import app as celery_app + +__all__ = ('celery_app',) + +_(u"username") +_(u"email address") +_(u"warehouse") +_(u"New warehouse") +_(u"warehouse") +_(u"New organization") +_(u"New person") +_(u"New author") diff --git a/example_project/celery.py.sample b/example_project/celery.py.sample new file mode 100644 index 000000000..3aed98038 --- /dev/null +++ b/example_project/celery.py.sample @@ -0,0 +1,18 @@ +import os +from celery import Celery + +# change example_project with your project name +project_name = "example_project" + +# set the default Django settings module for the 'celery' program. +os.environ.setdefault('DJANGO_SETTINGS_MODULE', project_name + '.settings') + +app = Celery(project_name) + +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))
\ No newline at end of file diff --git a/example_project/settings.py b/example_project/settings.py index 8a7343212..09590f807 100644 --- a/example_project/settings.py +++ b/example_project/settings.py @@ -273,7 +273,7 @@ DOT_BINARY = "" TEST_RUNNER = 'ishtar_common.tests.ManagedModelTestRunner' try: - from local_settings import * + from .local_settings import * except ImportError as e: print('Unable to load local_settings.py:', e) @@ -316,7 +316,7 @@ if DEBUG: LOGGING['loggers'][logger]['handlers'] += ['console'] if USE_BACKGROUND_TASK: - INSTALLED_APPS.append('background_task') + CELERY_BROKER_URL = 'amqp://localhost' if DJANGO_EXTENSIONS: INSTALLED_APPS.append('django_extensions') diff --git a/install/ishtar-prepare-instance b/install/ishtar-prepare-instance index e635dffef..fcc5cb629 100755 --- a/install/ishtar-prepare-instance +++ b/install/ishtar-prepare-instance @@ -261,6 +261,12 @@ EOF fi echo $UWSGI_PORT > $PORT_FILE + ### __init__.py + + cd $INSTANCE + # ln -s __init__.py.celery.sample __init__.py + ln -s __init__.py.base.sample __init__.py + ### local_settings.py sed -s "s|#APP_NAME#|$INSTANCE|g;\ diff --git a/requirements.txt b/requirements.txt index 8a0e8eaaf..53369ff4e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,8 @@ requests==2.12 dbf==0.96.003 python-memcached==1.57 -# django-background-tasks==1.1.11 ## not mandatory +# celery==4.2.1 ## not mandatory + pytidylib==0.3.2 lxml==3.4.0 |