-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (31 loc) · 1.25 KB
/
Copy pathmain.py
File metadata and controls
38 lines (31 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from __future__ import annotations
from loguru import logger
import asyncio
from typing import NoReturn
from sys import version_info
from src.massa import monitor_loop
from src.telegram import app_courier, courier_loop, bot_session
@logger.catch
async def main() -> NoReturn:
app_courier.append_message(text_message=f"🏃 Started!")
try:
async with asyncio.TaskGroup() as t_group:
def1_result = t_group.create_task(monitor_loop())
def2_result = t_group.create_task(courier_loop())
except BaseException as E:
logger.error(f"Coros failed: {def1_result=}, {def2_result=}")
await bot_session.close()
raise
if __name__ == "__main__":
logger.add(sink="logs/main.log", level="INFO",
format="{time} | {level}\t| {file.path}:{line} '{message}'",
backtrace=True, diagnose=True, enqueue=True,
rotation="1 day", retention="1 month", compression="zip")
logger.info(f"*** MASSA remote monitor starting...")
assert (version_info.major == 3 and version_info.minor >= 11), "You need Python version 3.11+ to run"
try:
asyncio.run(main=main())
except BaseException as E:
logger.error(E.__repr__())
finally:
logger.critical(f"*** MASSA remote monitor stopped")