video_downloader_service/main.py

33 lines
740 B
Python
Raw Normal View History

2023-10-18 00:38:33 +03:00
import asyncio
2023-11-29 16:15:48 +03:00
import json
from typing import Any
2023-08-24 16:45:55 +03:00
from multiprocessing import freeze_support
from src.core.master_service import MasterService
2023-11-29 16:15:48 +03:00
from loguru import logger
def json_logs(message: Any) -> None:
record = message.record
data = {
"timestamp": record["time"].strftime("%d.%m.%y %H.%M.%S %Z%z"),
"level": record["level"].name,
"message": record["message"],
"path": record["file"].path,
"function": record["function"],
"line": record["line"],
}
print(json.dumps(data))
logger.remove(0)
logger.add(json_logs)
2023-08-24 16:45:55 +03:00
if __name__ == '__main__':
freeze_support()
2023-10-18 00:47:58 +03:00
loop = asyncio.new_event_loop()
2023-10-18 00:38:33 +03:00
ms = MasterService(loop)
2023-10-17 18:14:32 +03:00
ms.loop.run_until_complete(ms.run())