fix: CLI serve 使用 load_config 避免主进程双重加载嵌入模型
- 用 load_config(config) 替代 get_state().config - 避免 CLI 主进程加载嵌入模型后 uvicorn 子进程再次加载 - 移除对 get_state 的隐式依赖(已有 DEFAULT_CONFIG_PATH 导入) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+4
-2
@@ -168,10 +168,12 @@ def serve(
|
||||
):
|
||||
# 传递 config 给 uvicorn 子进程 (通过环境变量)
|
||||
os.environ["MD_VECTOR_CONFIG"] = config
|
||||
# 使用 load_config 而非 get_state(),避免在 CLI 主进程加载嵌入模型
|
||||
from src.core.config import load_config
|
||||
|
||||
cfg = load_config(config)
|
||||
typer.echo(f"启动服务: http://localhost:{port}")
|
||||
typer.echo(f"API 文档: http://localhost:{port}/docs")
|
||||
# 加载配置以获取 SSL 设置
|
||||
cfg = get_state().config
|
||||
ssl_kwargs = {}
|
||||
if cfg.server.ssl_keyfile and cfg.server.ssl_certfile:
|
||||
ssl_kwargs["ssl_keyfile"] = cfg.server.ssl_keyfile
|
||||
|
||||
Reference in New Issue
Block a user