diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index 72f7b8fb5..84dbc8795 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -12,6 +12,14 @@ services: - "5433:5432" networks: - sapl-net-dev + + redis: + image: redis:latest + command: redis-server + ports: + - "6379:6379" + networks: + - sapl-net-dev sapl-dev: container_name: sapl-dev @@ -31,6 +39,7 @@ services: TZ: America/Sao_Paulo depends_on: - sapldb-dev + - redis networks: - sapl-net-dev diff --git a/requirements/requirements.txt b/requirements/requirements.txt index b45b64d9e..26d14251b 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -32,6 +32,6 @@ pysolr==3.6.0 PyPDF4==1.27.0 pyoai==2.5.0 Unidecode==1.1.1 - +celery git+https://github.com/interlegis/trml2pdf git+https://github.com/interlegis/django-admin-bootstrapped diff --git a/sapl/__init__.py b/sapl/__init__.py index e69de29bb..69159ff9f 100644 --- a/sapl/__init__.py +++ b/sapl/__init__.py @@ -0,0 +1,3 @@ +from .celery import celery_app + +__all__ = ('celery_app',) \ No newline at end of file diff --git a/sapl/celery.py b/sapl/celery.py new file mode 100644 index 000000000..75100f5fa --- /dev/null +++ b/sapl/celery.py @@ -0,0 +1,9 @@ + +import os +from celery import Celery + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sapl.settings') + +celery_app = Celery('sapl') +celery_app.config_from_object('django.conf:settings', namespace='CELERY') +celery_app.autodiscover_tasks() \ No newline at end of file diff --git a/sapl/materia/tasks.py b/sapl/materia/tasks.py new file mode 100644 index 000000000..7505779b5 --- /dev/null +++ b/sapl/materia/tasks.py @@ -0,0 +1,6 @@ +from celery import shared_task + +#teste +@shared_task +def adding_task(x, y): + return x + y \ No newline at end of file diff --git a/sapl/settings.py b/sapl/settings.py index 7212b0ca5..173a9c441 100644 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -99,7 +99,6 @@ INSTALLED_APPS = ( 'speedinfo', 'webpack_loader', - ) + SAPL_APPS # FTS = Full Text Search @@ -359,6 +358,12 @@ PASSWORD_HASHERS = [ 'sapl.hashers.ZopeSHA1PasswordHasher', ] +#celery +CELERY_BROKER_URL = 'redis://redis:6379/0' +CELERY_RESULT_BACKEND = 'redis://redis:6379/0' +CELERY_ACCEPT_CONTENT = ['application/json'] +CELERY_RESULT_SERIALIZER = 'json' +CELERY_TASK_SERIALIZER = 'json' def remove_warnings(): import warnings