e4e9eb0928becfa4e48484dde85ef5032671d582
1
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
7d5db0f29a |
cli: a command that ends ends its plugin hosts, and one that doesn't serve starts none (#7146)
athemeroy (WangYeruo on X) runs `magpie serve` as a LaunchAgent with the
magpie-google-ai-studio browser plugin and 11 accounts. Each
`magpie --version`, `version`, `licenses` or `group <id>` run beside it
left a second magpie-bun host with PPID 1, holding the Chrome profiles
the gateway's host wanted ("Chrome exited before starting WebView").
Their analysis was right on each count:
- plugin.Cached starts a background list of the plugins' providers
whenever this process hasn't listed them (provGood is in memory), so
every short command reaching provider.Catalog (startUp's RenameLegacy,
groups, models, ...) started a host.
- Main ended through os.Exit and never stopped it. A host whose stdin
closes leaves only once nothing is pending, and a plugin holding a
browser keeps Bun up meanwhile, so the host outlived magpie, adopted
by init. SIGTERM (launchd stopping serve) orphaned serve's own host
the same way.
- --version and licenses were answered after startUp.
Now:
- Cached asks the plugins in the background only when
plugin.ListInBackground is on; run sets it from servesPages (app,
web, serve, TUI). Other commands read the list on disk.
- Main ends through exit(), which runs plugin.EndHosts first, on
success and error; die does too on SIGINT/SIGTERM/SIGHUP, bounded by
hostsOnSignal (20s, past the 15s a renewing host gets).
- provider test returns exitError instead of os.Exit(1).
- -v/--version/version and licenses answer before any start-up work.
Audit of the os.Exit calls in internal/cli: data_cli.go:135 and the
CheckEnv exit in Main run before anything can start a host;
claudeLetGo already called EndHosts.
Tests (red on the old code, the non-test sources reverted to
|