File size: 895 Bytes
77169b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
"""
架构入口:启动 FastAPI 服务,baseUrl 为 http://ip:port/{type}/v1/...
示例:http://127.0.0.1:8000/claude/v1/chat/completions
"""

# 尽早设置,让 Chromium 派生的 Node 子进程继承,抑制 url.parse 等 DeprecationWarning
import os
import logging
import sys
import uvicorn

from core.config.settings import get_server_host, get_server_port, load_config

load_config()

_opt = os.environ.get("NODE_OPTIONS", "").strip()
if "--no-deprecation" not in _opt:
    os.environ["NODE_OPTIONS"] = (_opt + " --no-deprecation").strip()

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s [%(levelname)s] %(message)s",
    datefmt="%H:%M:%S",
)


def main() -> int:
    uvicorn.run(
        "core.app:app",
        host=get_server_host(),
        port=get_server_port(),
        reload=False,
    )
    return 0


if __name__ == "__main__":
    sys.exit(main())