Skip to content

Commit 3489816

Browse files
kevin314garg-amit
authored andcommitted
[Bugfix] Bind api server port before starting engine (vllm-project#8491)
Signed-off-by: Amit Garg <mitgarg17495@gmail.com>
1 parent ada3b2e commit 3489816

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

vllm/entrypoints/openai/api_server.py

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import re
77
import signal
8+
import socket
89
import tempfile
910
from argparse import Namespace
1011
from contextlib import asynccontextmanager
@@ -525,6 +526,9 @@ async def run_server(args, **uvicorn_kwargs) -> None:
525526
logger.info("vLLM API server version %s", VLLM_VERSION)
526527
logger.info("args: %s", args)
527528

529+
temp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
530+
temp_socket.bind(("", args.port))
531+
528532
def signal_handler(*_) -> None:
529533
# Interrupt server on sigterm while initializing
530534
raise KeyboardInterrupt("terminated")
@@ -541,6 +545,8 @@ def signal_handler(*_) -> None:
541545
model_config = await async_engine_client.get_model_config()
542546
init_app_state(async_engine_client, model_config, app.state, args)
543547

548+
temp_socket.close()
549+
544550
shutdown_task = await serve_http(
545551
app,
546552
limit_concurrency=async_engine_client.limit_concurrency,

0 commit comments

Comments
 (0)