26 lines
918 B
Python
26 lines
918 B
Python
"""本机启动入口:``python run.py``。
|
||
|
||
不设 ``OA_ENV`` 时读的是测试档(``config.toml`` + ``config.dev.toml``),连测试库、
|
||
种演示数据,怎么折腾都不碰生产。部署机上换生产档:``OA_ENV=prod ./scripts/prod-api.sh``,
|
||
规矩见 :mod:`app.config` 顶部注释与 README「配置项」一节。
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import uvicorn
|
||
|
||
from app.config import settings
|
||
|
||
if __name__ == "__main__":
|
||
# OA_WORKERS>1 就是同一台机器上多开几个 HTTP 进程(每个进程一个核)。后台任务照旧
|
||
# 只有一个进程在做:租约在库里,抢不到的进程自动不跑(docs/multi-worker-deployment.md)。
|
||
workers = max(1, int(settings.workers or 1))
|
||
uvicorn.run(
|
||
"app.main:app",
|
||
host=settings.host,
|
||
port=settings.port,
|
||
reload=False,
|
||
workers=workers,
|
||
log_level="info",
|
||
)
|