develop
Сергей Ванюшкин 2024-02-12 03:03:24 +03:00
parent f28637f5dd
commit 5e213e759d
3 changed files with 6 additions and 2 deletions

View File

@ -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'],
)

View File

@ -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')

View File

@ -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()