Skip to content

Commit

Permalink
Bind api server port before starting engine
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin314 committed Sep 16, 2024
1 parent 79c1b83 commit e4c932d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions vllm/entrypoints/openai/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import multiprocessing
import os
import re
import socket
import tempfile
from argparse import Namespace
from contextlib import asynccontextmanager
Expand Down Expand Up @@ -495,13 +496,18 @@ async def run_server(args, **uvicorn_kwargs) -> None:
logger.info("vLLM API server version %s", VLLM_VERSION)
logger.info("args: %s", args)

temp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
temp_socket.bind(("", args.port))

async with build_async_engine_client(args) as async_engine_client:
# If None, creation of the client failed and we exit.
if async_engine_client is None:
return

app = await init_app(async_engine_client, args)

temp_socket.close()

shutdown_task = await serve_http(
app,
engine=async_engine_client,
Expand Down

0 comments on commit e4c932d

Please sign in to comment.