fix(CRITICAL): launch_server.py用execvp启动api_server——import *不触发__main__

原来的 from vllm...api_server import * 只执行了 import 阶段的
side-effects (torch/tensorflow warnings), 但不触发 if __name__ == '__main__'
所以服务器永远不启动, 进程直接退出。

改用 os.execvp 替换进程为 python3 -m vllm.entrypoints.openai.api_server,
传递所有CLI参数, 这是force patch后最安全的启动方式。
This commit is contained in:
Claude
2026-08-11 10:45:35 +00:00
parent ba0f67e79e
commit d9064550b2

View File

@@ -45,5 +45,9 @@ def _force_patch():
_force_patch()
# Now run the standard vllm api_server with our patched version
from vllm.entrypoints.openai.api_server import *
# execvp replaces this process with vllm api_server, passing all CLI args through.
# This is the safest approach: no import issues, our patched files are already on disk.
print("[launch] Starting vllm api_server with args:", sys.argv[1:], file=sys.stderr)
os.execvp(sys.executable, [
sys.executable, "-m", "vllm.entrypoints.openai.api_server"
] + sys.argv[1:])