-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.py
36 lines (26 loc) · 1.13 KB
/
main.py
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
from app import rocket, create_global_exception_handler, register_middlewares, register_routers, init_logging, \
register_scheduler
from loguru import logger
from config import BANNER, ROCKET_ENV
@rocket.on_event("startup")
async def start_event():
init_logging()
logger.info("logging is init success!!!")
logger.success(f"rocket is running at <red>{ROCKET_ENV}</red>")
logger.success(BANNER)
# step1 注册路由
await register_routers(rocket)
logger.info("routers is register success!!!")
# step2 注册中间件
await register_middlewares(rocket)
logger.info("middlewares is register success!!!")
# step3 注册全局异常处理器
await create_global_exception_handler(rocket)
logger.info("exceptionHandler is register success!!!")
from app.models import Base, engine
# step4 向数据库发出建表完成类与表的映射
Base.metadata.create_all(engine)
logger.info("db is init success!!!")
await register_scheduler(rocket)
logger.info("ApScheduler started success!!!")
logger.info("Rocket is start success!!!")