-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (23 loc) · 716 Bytes
/
Copy pathmain.py
File metadata and controls
31 lines (23 loc) · 716 Bytes
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
import importlib
from app.config import get_settings
from app.startup import create_api_application, run_pool_mode_blocking
def main() -> None:
"""应用统一入口。
- MODE=api: 启动 FastAPI。
- MODE=pool: 启动号池后台循环。
"""
settings = get_settings()
mode = settings.mode.lower().strip()
if mode == "pool":
run_pool_mode_blocking(settings)
return
api_app = create_api_application(settings)
uvicorn_module = importlib.import_module("uvicorn")
uvicorn_module.run(
api_app,
host=settings.app_host,
port=settings.app_port,
log_level=settings.log_level.lower(),
)
if __name__ == "__main__":
main()