File tree 1 file changed +6
-0
lines changed
1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change 5
5
import os
6
6
import re
7
7
import signal
8
+ import socket
8
9
import tempfile
9
10
from argparse import Namespace
10
11
from contextlib import asynccontextmanager
@@ -525,6 +526,9 @@ async def run_server(args, **uvicorn_kwargs) -> None:
525
526
logger .info ("vLLM API server version %s" , VLLM_VERSION )
526
527
logger .info ("args: %s" , args )
527
528
529
+ temp_socket = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
530
+ temp_socket .bind (("" , args .port ))
531
+
528
532
def signal_handler (* _ ) -> None :
529
533
# Interrupt server on sigterm while initializing
530
534
raise KeyboardInterrupt ("terminated" )
@@ -541,6 +545,8 @@ def signal_handler(*_) -> None:
541
545
model_config = await async_engine_client .get_model_config ()
542
546
init_app_state (async_engine_client , model_config , app .state , args )
543
547
548
+ temp_socket .close ()
549
+
544
550
shutdown_task = await serve_http (
545
551
app ,
546
552
limit_concurrency = async_engine_client .limit_concurrency ,
You can’t perform that action at this time.
0 commit comments