Commit 7c84af700c226f8572f7690c0530a5da0f227fb9

Authored by Gust
Committed by Sergio Oliveira
1 parent 31499efd

Add celery to colab

Signed-off-by: Gustavo Jaruga <darksshades@gmail.com>
Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
colab/__init__.py
... ... @@ -0,0 +1,5 @@
  1 +from __future__ import absolute_import
  2 +
  3 +# This will make sure the app is always imported when
  4 +# Django starts so that shared_task will use this app.
  5 +from .celery import app as celery_app # noqa
... ...
colab/celery.py 0 → 100644
... ... @@ -0,0 +1,27 @@
  1 +from __future__ import absolute_import
  2 +
  3 +import os
  4 +
  5 +from celery import Celery
  6 +
  7 +# set the default Django settings module for the 'celery' program.
  8 +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'colab.settings')
  9 +
  10 +from django.conf import settings
  11 +
  12 +app = Celery('colab')
  13 +
  14 +app.config_from_object('django.conf:settings')
  15 +app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
  16 +
  17 +app.conf.update(
  18 + CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend',
  19 +)
  20 +app.conf.update(
  21 + CELERY_RESULT_BACKEND='djcelery.backends.cache:CacheBackend',
  22 +)
  23 +
  24 +
  25 +@app.task(bind=True)
  26 +def debug_task(self):
  27 + print('Request: {0!r}'.format(self.request))
... ...
colab/settings.py
... ... @@ -8,6 +8,7 @@ For the full list of settings and their values, see
8 8 https://docs.djangoproject.com/en/1.7/ref/settings/
9 9 """
10 10  
  11 +BROKER_URL = 'amqp://guest:guest@localhost:5672/'
11 12 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
12 13 import os
13 14 BASE_DIR = os.path.dirname(__file__)
... ... @@ -47,6 +48,7 @@ INSTALLED_APPS = (
47 48 'hitcounter',
48 49 'i18n_model',
49 50 'taggit',
  51 + 'djcelery',
50 52  
51 53 # Own apps
52 54 'colab.home',
... ...
setup.py
... ... @@ -14,6 +14,9 @@ REQUIREMENTS = [
14 14 # Diazo
15 15 'diazo>=1.0.5',
16 16  
  17 + # Celery
  18 + 'django-celery==3.1.16',
  19 +
17 20 ### Move out of colab (as plugins):
18 21  
19 22 # Deps for badger
... ...
vagrant/centos.sh
... ... @@ -21,6 +21,10 @@ yum -y groupinstall &quot;Development tools&quot;
21 21  
22 22 yum install -y git unzip mercurial libev-devel gettext libxml2-devel libxslt-devel openssl-devel libffi-devel libjpeg-turbo-devel zlib-devel freetype-devel postgresql-devel python-devel postgresql-server java epel-release
23 23  
  24 +### Install Rabbitmq
  25 +yum install -y rabbitmq-server
  26 +systemctl start rabbitmq-server
  27 +
24 28 ### Install Virtualenvwrapper
25 29 which pip2.7 > /dev/null ||
26 30 curl -s -L https://raw.githubusercontent.com/pypa/pip/1.5.6/contrib/get-pip.py |
... ...