Skip to content

Commit

Permalink
[ci] try to log process using the port to debug the port usage (vllm-…
Browse files Browse the repository at this point in the history
  • Loading branch information
youkaichao authored Aug 21, 2024
1 parent 66a9e71 commit b74a125
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions vllm/entrypoints/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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__)

Expand Down Expand Up @@ -48,6 +49,12 @@ async def dummy_shutdown() -> None:
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()

Expand Down
10 changes: 10 additions & 0 deletions vllm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b74a125

Please sign in to comment.