Skip to content

Commit

Permalink
[Frontend] Fix tcp port reservation for api server (vllm-project#10012)
Browse files Browse the repository at this point in the history
Signed-off-by: Russell Bryant <[email protected]>
  • Loading branch information
russellb authored and weilong.yu committed Dec 13, 2024
1 parent a39b0a4 commit 73ae504
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions vllm/entrypoints/openai/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,8 @@ async def run_server(args, **uvicorn_kwargs) -> None:
# This avoids race conditions with ray.
# see https://github.com/vllm-project/vllm/issues/8204
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("", args.port))
sock.bind((args.host or "", args.port))
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

def signal_handler(*_) -> None:
# Interrupt server on sigterm while initializing
Expand All @@ -593,13 +594,14 @@ def signal_handler(*_) -> None:
ssl_certfile=args.ssl_certfile,
ssl_ca_certs=args.ssl_ca_certs,
ssl_cert_reqs=args.ssl_cert_reqs,
fd=sock.fileno(),
**uvicorn_kwargs,
)

# NB: Await server shutdown only after the backend context is exited
await shutdown_task

sock.close()


if __name__ == "__main__":
# NOTE(simon):
Expand Down

0 comments on commit 73ae504

Please sign in to comment.