refactored docker-compose

This commit is contained in:
2023-11-29 16:15:48 +03:00
committed by nikili0n
parent d984566a88
commit 0651fb6ff0
6 changed files with 80 additions and 9 deletions

View File

@ -14,7 +14,7 @@ async def on_message(message: AbstractIncomingMessage, queue) -> None:
async def get_messages(inner_queue) -> None:
async with await connect("amqp://guest:guest@localhost/") as connection:
async with await connect("amqp://guest:guest@rabbitmq/") as connection:
channel = await connection.channel()
await channel.set_qos(prefetch_count=1)
@ -30,7 +30,7 @@ async def get_messages(inner_queue) -> None:
async def publish_message_with_task_done(task: dict | list) -> None:
queue_name = "tasks_done"
async with await connect("amqp://guest:guest@localhost/") as connection:
async with await connect("amqp://guest:guest@rabbitmq/") as connection:
# Creating channel
channel = await connection.channel()

View File

@ -9,7 +9,7 @@ class RedisClient:
TASKS_DONE_NAME = "tasks_done"
def __init__(self):
self.connection = redis.Redis(host="localhost", port=6379, db=0)
self.connection = redis.Redis(host="redis_video_downloader", port=6379, db=0)
async def _set_task(self, queue_name: str, link: str, task: dict | list, ) -> int:
async with self.connection as connection:

View File

@ -1,4 +1,5 @@
import json
import os
import uvicorn
import logging
@ -15,8 +16,7 @@ from src.web.schemes.submit import SubmitIn, CheckIn, DeleteFromS3, CopyToAnothe
app = FastAPI(
title="video_downloader", openapi_url=f"/api/v1/openapi.json"
)
templates = Jinja2Templates(directory="templates")
templates = Jinja2Templates(directory=f"{os.path.dirname(os.path.dirname(os.path.abspath(__file__)))}/web/templates")
app.add_middleware(
CORSMiddleware,
@ -102,7 +102,7 @@ async def get_url_for_download_video(request: Request, data: SubmitIn = Depends(
return JSONResponse({"result": links_to_download_video})
# TODO: учесть, что если делать запрос CURL\urllib3\etc, в теле может быть несколько ссылок -> должно быть создано несколько задач
async with await connect("amqp://guest:guest@localhost/") as connection:
async with await connect("amqp://guest:guest@rabbitmq/") as connection:
# Creating a channel
channel = await connection.channel()
body = [
@ -204,4 +204,4 @@ async def delete_video_from_s3(data: CopyToAnotherBucketS3):
)
uvicorn.run("src.web.main:app", host="0.0.0.0", log_level="info")
uvicorn.run("src.web.main:app", host="0.0.0.0", port=8000, log_level="info")