Commit 7c84af700c226f8572f7690c0530a5da0f227fb9
Committed by
Sergio Oliveira
1 parent
31499efd
Exists in
plugin_extra_configs
Add celery to colab
Signed-off-by: Gustavo Jaruga <darksshades@gmail.com> Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
Showing
5 changed files
with
41 additions
and
0 deletions
Show diff stats
colab/__init__.py
| @@ -0,0 +1,27 @@ | @@ -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,6 +8,7 @@ For the full list of settings and their values, see | ||
| 8 | https://docs.djangoproject.com/en/1.7/ref/settings/ | 8 | https://docs.djangoproject.com/en/1.7/ref/settings/ |
| 9 | """ | 9 | """ |
| 10 | 10 | ||
| 11 | +BROKER_URL = 'amqp://guest:guest@localhost:5672/' | ||
| 11 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) | 12 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) |
| 12 | import os | 13 | import os |
| 13 | BASE_DIR = os.path.dirname(__file__) | 14 | BASE_DIR = os.path.dirname(__file__) |
| @@ -47,6 +48,7 @@ INSTALLED_APPS = ( | @@ -47,6 +48,7 @@ INSTALLED_APPS = ( | ||
| 47 | 'hitcounter', | 48 | 'hitcounter', |
| 48 | 'i18n_model', | 49 | 'i18n_model', |
| 49 | 'taggit', | 50 | 'taggit', |
| 51 | + 'djcelery', | ||
| 50 | 52 | ||
| 51 | # Own apps | 53 | # Own apps |
| 52 | 'colab.home', | 54 | 'colab.home', |
setup.py
| @@ -14,6 +14,9 @@ REQUIREMENTS = [ | @@ -14,6 +14,9 @@ REQUIREMENTS = [ | ||
| 14 | # Diazo | 14 | # Diazo |
| 15 | 'diazo>=1.0.5', | 15 | 'diazo>=1.0.5', |
| 16 | 16 | ||
| 17 | + # Celery | ||
| 18 | + 'django-celery==3.1.16', | ||
| 19 | + | ||
| 17 | ### Move out of colab (as plugins): | 20 | ### Move out of colab (as plugins): |
| 18 | 21 | ||
| 19 | # Deps for badger | 22 | # Deps for badger |
vagrant/centos.sh
| @@ -21,6 +21,10 @@ yum -y groupinstall "Development tools" | @@ -21,6 +21,10 @@ yum -y groupinstall "Development tools" | ||
| 21 | 21 | ||
| 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 | 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 | ### Install Virtualenvwrapper | 28 | ### Install Virtualenvwrapper |
| 25 | which pip2.7 > /dev/null || | 29 | which pip2.7 > /dev/null || |
| 26 | curl -s -L https://raw.githubusercontent.com/pypa/pip/1.5.6/contrib/get-pip.py | | 30 | curl -s -L https://raw.githubusercontent.com/pypa/pip/1.5.6/contrib/get-pip.py | |