fix
parent
f28637f5dd
commit
5e213e759d
|
@ -2,6 +2,8 @@ import asyncio
|
||||||
|
|
||||||
from celery import Celery
|
from celery import Celery
|
||||||
|
|
||||||
|
from fastfood.config import settings
|
||||||
|
|
||||||
from .updater import main
|
from .updater import main
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
@ -9,7 +11,7 @@ loop = asyncio.get_event_loop()
|
||||||
|
|
||||||
celery_app = Celery(
|
celery_app = Celery(
|
||||||
'tasks',
|
'tasks',
|
||||||
broker='amqp://guest:guest@rabbitmq',
|
broker=settings.REBBITMQ_URL,
|
||||||
backend='rpc://',
|
backend='rpc://',
|
||||||
include=['bg_tasks.bg_task'],
|
include=['bg_tasks.bg_task'],
|
||||||
)
|
)
|
||||||
|
|
|
@ -75,7 +75,7 @@ class Settings(BaseSettings):
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
return 'amqp://guest:guest@rabbitmq'
|
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')
|
model_config = SettingsConfigDict(env_file='.env')
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,12 @@ async def recreate() -> None:
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if '--run-docker-server' in sys.argv:
|
if '--run-docker-server' in sys.argv:
|
||||||
|
"""Запуск FastAPI в докере. Celery запускается в отдельном контейнере"""
|
||||||
loop.run_until_complete(recreate())
|
loop.run_until_complete(recreate())
|
||||||
loop.run_until_complete(run_app())
|
loop.run_until_complete(run_app())
|
||||||
|
|
||||||
if '--run-local-server' in sys.argv:
|
if '--run-local-server' in sys.argv:
|
||||||
|
"""Локальный запуск FastAPI с запуском Celery в отдельных процессах"""
|
||||||
celery_worker_process.start()
|
celery_worker_process.start()
|
||||||
celery_beat_process.start()
|
celery_beat_process.start()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue