From 8b7cdef9903deb318368efbec0b76173336eab6a Mon Sep 17 00:00:00 2001 From: Yujong Lee Date: Tue, 3 Nov 2026 06:32:23 +0900 Subject: [PATCH] refactor(proxy): pass the supervised children's environment into supervise Co-Authored-By: Claude Opus 5.5 --- litellm/proxy/proxy_cli.py | 2 +- litellm/proxy/rust_gateway.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/litellm/proxy/proxy_cli.py b/litellm/proxy/proxy_cli.py index 8a3d85c81b3..68db6d3f316 100644 --- a/litellm/proxy/proxy_cli.py +++ b/litellm/proxy/proxy_cli.py @@ -1309,7 +1309,7 @@ def run_server( public_port: Final = ( random.randint(1024, 49152) if port == 4000 and ProxyInitializationHelpers.is_port_in_use(port) else port ) - raise SystemExit(supervise(binary, cli_command(sys.argv[1:]), host, public_port)) + raise SystemExit(supervise(binary, cli_command(sys.argv[1:]), host, public_port, os.environ)) supervised: Final = gateway_mode if isinstance(gateway_mode, Supervised) else None args: Final = locals() diff --git a/litellm/proxy/rust_gateway.py b/litellm/proxy/rust_gateway.py index 9a2d61f09f7..f2ebd870853 100644 --- a/litellm/proxy/rust_gateway.py +++ b/litellm/proxy/rust_gateway.py @@ -224,7 +224,7 @@ async def _drive( return await _drive(following, events, children) -async def _supervise(binary: str, command: Sequence[str], host: str, port: int) -> ExitCode: +async def _supervise(binary: str, command: Sequence[str], host: str, port: int, environ: Mapping[str, str]) -> ExitCode: loop: Final = asyncio.get_running_loop() events: Final[asyncio.Queue[Event]] = asyncio.Queue() for signum in (signal.SIGTERM, signal.SIGINT): @@ -233,9 +233,9 @@ async def _supervise(binary: str, command: Sequence[str], host: str, port: int) listener.bind((RUST_HOP, 0)) listener.listen() _, upstream_port = _ADDRESS.validate_python(listener.getsockname()) - python: Final = await _spawn(python_spec(command, listener.fileno(), upstream_port, host, os.environ)) + python: Final = await _spawn(python_spec(command, listener.fileno(), upstream_port, host, environ)) try: - rust: Final = await _spawn(rust_spec(binary, upstream_port, host, port, os.environ)) + rust: Final = await _spawn(rust_spec(binary, upstream_port, host, port, environ)) except OSError: _terminate_group(python) await python.wait() @@ -252,9 +252,9 @@ async def _supervise(binary: str, command: Sequence[str], host: str, port: int) await asyncio.gather(*waiters) -def supervise(binary: str, command: Sequence[str], host: str, port: int) -> int: +def supervise(binary: str, command: Sequence[str], host: str, port: int, environ: Mapping[str, str]) -> int: try: - return asyncio.run(_supervise(binary, command, host, port)) + return asyncio.run(_supervise(binary, command, host, port, environ)) except OSError as error: sys.stderr.write(f"Rust gateway startup failed: {error}\n") return ExitCode.CHILD_FAILED