diff --git a/admin/.~lock.Menu.xlsx# b/admin/.~lock.Menu.xlsx# deleted file mode 100644 index 4cab078..0000000 --- a/admin/.~lock.Menu.xlsx# +++ /dev/null @@ -1 +0,0 @@ -,pi3c,pi3code,12.02.2024 22:20,file:///home/pi3c/.config/libreoffice/4; diff --git a/bg_tasks/bg_task.py b/bg_tasks/bg_task.py index 2b86b54..69ae5e0 100644 --- a/bg_tasks/bg_task.py +++ b/bg_tasks/bg_task.py @@ -4,7 +4,7 @@ from celery import Celery from fastfood.config import settings -from .updater import main +from .updater import main, main_gsheets loop = asyncio.get_event_loop() @@ -23,6 +23,26 @@ celery_app.conf.beat_schedule = { }, } +celery_app_google = Celery( + 'tasks', + broker=settings.REBBITMQ_URL, + backend='rpc://', + include=['bg_tasks.bg_task'], +) + +celery_app_google.conf.beat_schedule = { + 'run-task-every-15-seconds': { + 'task': 'bg_tasks.bg_task.periodic_task_google', + 'schedule': 30.0, + }, +} + + +@celery_app_google.task +def periodic_task_google() -> None: + result = loop.run_until_complete(main_gsheets()) + return result + @celery_app.task def periodic_task() -> None: diff --git a/compose_google.yml b/compose_google.yml new file mode 100644 index 0000000..ab8b3a9 --- /dev/null +++ b/compose_google.yml @@ -0,0 +1,112 @@ +version: "3.8" +services: + redis: + container_name: redis_test + + image: redis:7.2.4-alpine3.19 + + ports: + - '6380:6379' + + healthcheck: + test: [ "CMD", "redis-cli","ping" ] + interval: 10s + timeout: 5s + retries: 5 + + db: + container_name: pgdb + + image: postgres:15.1-alpine + + env_file: + - .env + + environment: + POSTGRES_DB: ${POSTGRES_DB} + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + + ports: + - 6432:5432 + + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] + interval: 10s + timeout: 5s + retries: 5 + + + app: + container_name: fastfood_app + + build: + context: . + + env_file: + - .env + + ports: + - 8000:8000 + + depends_on: + db: + condition: service_healthy + redis: + condition: service_healthy + + restart: always + + volumes: + - .:/usr/src/fastfood + + command: /bin/bash -c 'poetry run python /usr/src/fastfood/manage.py --run-docker-server' + + celery_worker: + container_name: celeryworker + + build: + context: . + + env_file: + - .env + + depends_on: + - rabbitmq + - db + - app + - redis + + volumes: + - .:/usr/src/fastfood + + command: ["celery", "-A", "bg_tasks.bg_task:celery_app_google", "worker", "--loglevel=info", "--concurrency", "1", "-P", "solo"] + + celery_beat: + container_name: celerybeat + + build: + context: . + + env_file: + - .env + + depends_on: + - rabbitmq + - db + - app + - redis + + volumes: + - .:/usr/src/fastfood + + command: ["celery", "-A", "bg_tasks.bg_task:celery_app_google", "beat", "--loglevel=info"] + + + rabbitmq: + container_name: rabbit + + image: "rabbitmq:management" + + ports: + - 5672:5672