[ci] try to log process using the port to debug the port usage (#7711)
This commit is contained in:
parent
66a9e713a7
commit
b74a125800
@ -10,6 +10,7 @@ from vllm import envs
|
||||
from vllm.engine.async_llm_engine import AsyncEngineDeadError
|
||||
from vllm.engine.protocol import AsyncEngineClient
|
||||
from vllm.logger import init_logger
|
||||
from vllm.utils import find_process_using_port
|
||||
|
||||
logger = init_logger(__name__)
|
||||
|
||||
@ -48,6 +49,12 @@ async def serve_http(app: FastAPI, engine: AsyncEngineClient,
|
||||
await server_task
|
||||
return dummy_shutdown()
|
||||
except asyncio.CancelledError:
|
||||
port = uvicorn_kwargs["port"]
|
||||
process = find_process_using_port(port)
|
||||
if process is not None:
|
||||
logger.debug(
|
||||
"port %s is used by process %s launched with command:\n%s",
|
||||
port, process, " ".join(process.cmdline()))
|
||||
logger.info("Gracefully stopping http server")
|
||||
return server.shutdown()
|
||||
|
||||
|
||||
@ -547,6 +547,16 @@ def get_open_port() -> int:
|
||||
return s.getsockname()[1]
|
||||
|
||||
|
||||
def find_process_using_port(port: int) -> Optional[psutil.Process]:
|
||||
for conn in psutil.net_connections():
|
||||
if conn.laddr.port == port:
|
||||
try:
|
||||
return psutil.Process(conn.pid)
|
||||
except psutil.NoSuchProcess:
|
||||
return None
|
||||
return None
|
||||
|
||||
|
||||
def update_environment_variables(envs: Dict[str, str]):
|
||||
for k, v in envs.items():
|
||||
if k in os.environ and os.environ[k] != v:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user