Skip to content

Plugin supervisor: its own file, plugins killed on quit, stderr capped - #16

Merged
sn merged 2 commits into
mainfrom
refactor/plugin-supervisor
Nov 19, 2026
Merged

sn merged 2 commits into
mainfrom
refactor/plugin-supervisor

Conversation

@sn

@sn sn commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

The last structural item from the 1.3.1 review: a dedicated place for running plugins. Two commits, a pure move and then the changes.

1. The move. src/plugins.rs becomes src/plugins/mod.rs (manifests, discovery, approvals, update checks) and src/plugins/supervisor.rs (each plugin's process, its settings and commands). Line for line the same code, apart from module boilerplate and two include_str! paths that follow the new folder.

2. The supervisor.

  • A Process type owns a plugin's process: starting it in a process group of its own, signalling the group, the stop deadline, and never signalling a pid that has been waited for. That was spread over five functions and two structs.
  • Quitting kills plugins that ignore being asked. Lumen used to send SIGTERM and exit, so the two-second SIGKILL never came and a plugin that ignored SIGTERM outlived it. Quitting now waits up to half a second, then kills what's left and whatever it started. A plugin that exits when asked costs no wait.
  • A stderr line is capped at 16 KB. One endless line could grow Lumen's memory without limit. Longer lines are logged in pieces, and bytes that aren't UTF-8 no longer end the log reader, which could leave the plugin blocked on a full pipe.
  • docs/plugin-protocol.md said the two-second kill applied on quit too. It now says what happens.

Two new tests: the quit deadline (a plugin that exits when asked, and one that ignores SIGTERM along with its child) and the stderr cap. 261 Rust tests pass locally. Not yet tried by hand: quitting a running Lumen with a plugin that ignores SIGTERM.

Not done here: messages from Lumen to a plugin queue without a bound, so a plugin that subscribes to events and never reads them grows Lumen's memory. That is in the writer src/api.rs shares with socket clients.

sn added 2 commits November 19, 2026 17:36
plugins.rs becomes plugins/mod.rs (manifests, discovery, approvals, update checks) and plugins/supervisor.rs (each plugin's process, its settings and commands). Code is moved, not changed; the two embedded-file paths follow the new folder.
… stderr lines capped

A Process owns a plugin's process group, its signals and its stop deadline, and never signals a pid that has been waited for. Quitting now waits up to half a second for plugins and then kills them and what they started: before, Lumen exited first and one that ignored SIGTERM lived on. A stderr line over 16 KB is logged in pieces instead of growing in memory, and bytes that aren't UTF-8 no longer end the log.
@sn sn self-assigned this Nov 19, 2026
@sn
sn merged commit 66d1255 into main Nov 19, 2026
2 checks passed
@sn
sn deleted the refactor/plugin-supervisor branch November 19, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant