From 5e213e759dfcaa4189b3b7994bf1e564aabc721a Mon Sep 17 00:00:00 2001 From: pi3c Date: Mon, 12 Feb 2024 03:03:24 +0300 Subject: [PATCH] fix --- bg_tasks/bg_task.py | 4 +++- fastfood/config.py | 2 +- manage.py | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bg_tasks/bg_task.py b/bg_tasks/bg_task.py index 1959e26..3703ea6 100644 --- a/bg_tasks/bg_task.py +++ b/bg_tasks/bg_task.py @@ -2,6 +2,8 @@ import asyncio from celery import Celery +from fastfood.config import settings + from .updater import main loop = asyncio.get_event_loop() @@ -9,7 +11,7 @@ loop = asyncio.get_event_loop() celery_app = Celery( 'tasks', - broker='amqp://guest:guest@rabbitmq', + broker=settings.REBBITMQ_URL, backend='rpc://', include=['bg_tasks.bg_task'], ) diff --git a/fastfood/config.py b/fastfood/config.py index 62a8891..8409f07 100644 --- a/fastfood/config.py +++ b/fastfood/config.py @@ -75,7 +75,7 @@ class Settings(BaseSettings): if os.path.exists(file_path): return 'amqp://guest:guest@rabbitmq' - return f'redis://{self.REDIS_HOST}:{self.REDIS_PORT}/{self.REDIS_DB}' + return 'amqp://guest:guest@127.0.0.1' model_config = SettingsConfigDict(env_file='.env') diff --git a/manage.py b/manage.py index b502fd2..639f437 100644 --- a/manage.py +++ b/manage.py @@ -43,10 +43,12 @@ async def recreate() -> None: if __name__ == '__main__': if '--run-docker-server' in sys.argv: + """Запуск FastAPI в докере. Celery запускается в отдельном контейнере""" loop.run_until_complete(recreate()) loop.run_until_complete(run_app()) if '--run-local-server' in sys.argv: + """Локальный запуск FastAPI с запуском Celery в отдельных процессах""" celery_worker_process.start() celery_beat_process.start()