refactor(proxy): pass the supervised children's environment into supervise

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Yujong Lee 2026-11-03 06:32:23 +09:00
parent 077d903211
commit 8b7cdef990
2 changed files with 6 additions and 6 deletions

View file

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

View file

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