From 68db31a033469c1c135e8d13362bc015786292d1 Mon Sep 17 00:00:00 2001 From: pi3c Date: Mon, 12 Feb 2024 00:54:53 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20?= =?UTF-8?q?=D1=83=D1=80=D0=BB=D0=B0=20=D0=BA=D1=80=D0=BE=D0=BB=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bg_tasks/bg_task.py | 3 ++- fastfood/config.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bg_tasks/bg_task.py b/bg_tasks/bg_task.py index c73b51e..ddf7360 100644 --- a/bg_tasks/bg_task.py +++ b/bg_tasks/bg_task.py @@ -2,6 +2,7 @@ import asyncio from celery import Celery +from ..fastfood.config import settings from .updater import main loop = asyncio.get_event_loop() @@ -9,7 +10,7 @@ loop = asyncio.get_event_loop() celery_app = Celery( 'tasks', - broker='amqp://guest:guest@localhost', + broker=settings.REBBITMQ_URL, backend='rpc://', include=['bg_tasks.bg_task'], ) diff --git a/fastfood/config.py b/fastfood/config.py index 7420230..4bd39c9 100644 --- a/fastfood/config.py +++ b/fastfood/config.py @@ -66,6 +66,17 @@ class Settings(BaseSettings): return f'redis://{self.REDIS_HOST}:{self.REDIS_PORT}/{self.REDIS_DB}' + @property + def REBBITMQ_URL(self): + """ + Возвращает строку подключения к REBBITMQ + """ + file_path = '/usr/src/RUN_IN_DOCKER' + if os.path.exists(file_path): + return 'amqp://guest:guest@localhost' + + # return f"redis://{self.REDIS_HOST}:{self.REDIS_PORT}/{self.REDIS_DB}" + model_config = SettingsConfigDict(env_file='.env')