Fix autostart and reload lifecycle with process tracking - #53
Merged
Merged
Conversation
Archer-01
reviewed
Aug 27, 2026
Archer-01
reviewed
Aug 27, 2026
Reloading with a smaller numprocs previously raced the shrink-Resize against still-running worker goroutines, causing an index-out-of-range panic (e.g. "[64] with length 3"), and trying to wait for these workers exposed a double-Wait deadlock and a restart-on-stop race. Stop() no longer calls cmds[i].Wait() (the worker already waits on the same *exec.Cmd, so a second concurrent Wait never returns). _running[i] is now owned solely by the worker's deferred cleanup, which runs last, so Stop waits for _running[i] to clear - re-killing the worker's current process group (which can change on restart) until it terminates - before returning. This guarantees all removed workers have fully exited before Resize truncates the per-proc slices.
Archer-01
approved these changes
Aug 27, 2026
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.
Fix
Stopno longer callscmds[i].Wait()(the worker already waits on the same*exec.Cmd)._running[i]is now owned solely by the worker's deferred cleanup (runs last), soStopwaits for_running[i]to clear — re-killing the worker's current process group until it truly terminates — before returning.Resizetruncates the per-proc slices, so resizing never runs out from under a live worker.Verified: shrink
numprocs70→3→5 and grow 3→70 viaSIGHUPreload; no panic, no hang, correct process counts.