Repository navigation
feat(launcher): persist spawned proxy for reuse across clients + bili stop - #136
Closed
ranxianglei wants to merge 1 commit into
Closed
ranxianglei wants to merge 1 commit into
ranxianglei wants to merge 1 commit into
Conversation
… stop Per user direction (改成复用): the launcher's spawned proxy now persists after the client exits, so subsequent 'bili <client>' invocations reuse it instead of spawning a new one. This makes reuse robust across terminals (the detached proxy survives terminal close — it was already detached:true, but runLaunch killed it on client exit, defeating reuse). - ensureProxyRunning writes a PID file (~/.local/share/billion-context/ launcher-proxy-<port>.pid) after a successful spawn. - runLaunch no longer kills the spawned proxy on client exit; logs 'proxy left running at ORIGIN for reuse (run bili stop to terminate)'. - runTestPi (bili test pi smoke) KEEPS kill-on-exit (one-off, clean up). - New 'bili stop' command reads all launcher-proxy-*.pid files, kills the processes, removes the files. stopLauncherProxy() exported for cli.ts. - HELP updated. Discovery (#125, merged) ensures the standing/spawned proxy covers ALL client domains at runtime (isMitmHost → discoverMitmDomains), so reuse always finds a domain-matching proxy. 343/343 tests, typecheck clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Launcher-spawned proxies now persist after the client exits and are reused by subsequent
bili <client>invocations on the same port, instead of one-proxy-per-invocation (deterministic cleanup was fragile — see #24 floor 103: a reused proxy dying when its owning terminal closed broke other terminals' clients).Changes
ensureProxyRunning: removed thedomainsNeedFreshProxygate. After feat(mitm): auto-discover model domains from client configs (no hardcoding) #125 (MITM discovery), the proxy discovers ALL client domains at runtime, so a running proxy covers every client. The gate was obsolete AND harmful (open.bigmodel.cnwas removed fromDEFAULT_MITM_DOMAINSin feat(mitm): auto-discover model domains from client configs (no hardcoding) #125, so the gate always forced a fresh spawn for pi/ZCode → never reused). Reuse is now pure health-probe.runLaunch: removedstopProxyin the finally block. The spawned proxy (alreadydetached:true+unref) now persists after the client exits; logsproxy left running at ORIGIN for reuse (run "bili stop" to terminate).runTestPi(one-off smoke) keeps its cleanup.bili stop(new command): reads~/.local/share/billion-context/launcher-proxy-<port>.pidfiles, kills the persisted proxies, removes stale PID files (handles ESRCH). Only stops launcher-spawned proxies — a standingbili startis left alone.launcherPidFile(port, env),stopLauncherProxy(env).Verified
bili test pilogsreusing existing proxy at http://127.0.0.1:8787(not a fresh spawn).bili stopcleans up./__bili/health→ 200.bili test pi✓ (GLM via MITM),bili codex exec✓ (MITM ai.comfly.org, replied REGRESS-CODEX). (claude needs ANTHROPIC auth; opencode uses the extension + standing proxy, not the launcher.)Lifecycle
bili pi→ spawns (or reuses) proxy on 8787 → runs pi → proxy persists.bili codex(next) → reuses the persisted 8787 proxy.bili stop→ terminates the persisted launcher proxy(es).bili startis reused identically (and is NOT stopped bybili stop).