Skip to content
Snippets Groups Projects
Commit fa51fdb2 authored by Hartung, Michael's avatar Hartung, Michael
Browse files

Merge branch 'celery' into development

Former-commit-id: d76d99f039edd4d658d4acde9fecaa7df61be77d [formerly bda14c622344246bcaf21c47e63faa5a5396ff3c]
Former-commit-id: c5b7ce4721eda9d1d13b70ca0f451ad5af19354f
parents 72b94c47 94c2fd8a
No related branches found
No related tags found
No related merge requests found
...@@ -18,10 +18,10 @@ check:test: ...@@ -18,10 +18,10 @@ check:test:
- python manage.py test - python manage.py test
deploy:dev: deploy:dev:
image: registry.blitzhub.io/docker
stage: deploy
only: only:
- development - development
image: registry.blitzhub.io/docker
stage: deploy
services: services:
- name: registry.blitzhub.io/docker:dind - name: registry.blitzhub.io/docker:dind
alias: docker alias: docker
...@@ -37,11 +37,11 @@ deploy:dev: ...@@ -37,11 +37,11 @@ deploy:dev:
- check:lint - check:lint
- check:test - check:test
deploy:prod: deploy:prod:
image: registry.blitzhub.io/docker
stage: deploy
only: only:
- production - production
image: registry.blitzhub.io/docker
stage: deploy
when: manual when: manual
services: services:
- name: registry.blitzhub.io/docker:dind - name: registry.blitzhub.io/docker:dind
......
...@@ -47,6 +47,27 @@ services: ...@@ -47,6 +47,27 @@ services:
hostname: redis hostname: redis
networks: networks:
- redis_net - redis_net
celery:
restart: always
build: .
command: celery -A core worker -l info
volumes:
- ./:/usr/src/app/
depends_on:
- redis
- db
networks:
- redis_net
celery-beat:
build: .
command: celery -A core beat -l info
volumes:
- ./:/usr/src/app/
depends_on:
- redis
- db
networks:
- redis_net
networks: networks:
db_net: db_net:
......
...@@ -3,6 +3,12 @@ ...@@ -3,6 +3,12 @@
python3 manage.py migrate --run-syncdb python3 manage.py migrate --run-syncdb
python3 manage.py createfixtures python3 manage.py createfixtures
python3 manage.py cleanuptasks python3 manage.py cleanuptasks
# sh import-data.sh
file="docker-entrypoint.lock"
# exit if entrypoint.lock exists to prevent new import of data every time docker is restarted
if ! test -f "$file"; then
sh import-data.sh
touch $file
fi
/usr/bin/supervisord -c "/etc/supervisor/conf.d/supervisord.conf" /usr/bin/supervisord -c "/etc/supervisor/conf.d/supervisord.conf"
...@@ -12,6 +12,9 @@ https://docs.djangoproject.com/en/3.0/ref/settings/ ...@@ -12,6 +12,9 @@ https://docs.djangoproject.com/en/3.0/ref/settings/
import os import os
# celery beat
from celery.schedules import crontab
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
...@@ -169,3 +172,13 @@ CACHES = { ...@@ -169,3 +172,13 @@ CACHES = {
} }
} }
} }
CELERY_BROKER_URL = "redis://redis:6379"
CELERY_RESULT_BACKEND = "redis://redis:6379"
CELERY_BEAT_SCHEDULE = {
"update_db": {
"task": "control.celery_tasks.task_update_db_from_nedrex",
"schedule": crontab(minute="*/3"),
}
}
...@@ -28,4 +28,5 @@ rq==1.3.0 ...@@ -28,4 +28,5 @@ rq==1.3.0
six==1.15.0 six==1.15.0
sqlparse==0.3.1 sqlparse==0.3.1
urllib3==1.25.10 urllib3==1.25.10
sqlalchemy==1.3.23 sqlalchemy==1.3.23
\ No newline at end of file celery==5.1.2
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment