[ci] try to log process using the port to debug the port usage (#7711)

This commit is contained in:
youkaichao 2024-08-20 17:41:12 -07:00 committed by GitHub
parent 66a9e713a7
commit b74a125800
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View File

@ -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()

View File

@ -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: