Skip to content

Fix autostart and reload lifecycle with process tracking - #53

Merged
Archer-01 merged 9 commits into
mainfrom
fix/autostart-on-reload
Aug 27, 2026
Merged

Archer-01 merged 9 commits into
mainfrom
fix/autostart-on-reload

Conversation

@mylastresort

@mylastresort mylastresort commented Aug 24, 2026 •

Copy link
Copy Markdown
Collaborator

Fix

  • Stop no longer calls cmds[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), so Stop waits for _running[i] to clear — re-killing the worker's current process group until it truly terminates — before returning.
  • This guarantees all removed workers have fully exited before Resize truncates the per-proc slices, so resizing never runs out from under a live worker.

Verified: shrink numprocs 70→3→5 and grow 3→70 via SIGHUP reload; no panic, no hang, correct process counts.

Comment thread Dockerfile
Comment thread setup.toml
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.
@mylastresort
mylastresort requested a review from Archer-01 August 27, 2026 19:14
@Archer-01
Archer-01 merged commit 284092f into main Aug 27, 2026
1 check passed
@Archer-01
Archer-01 deleted the fix/autostart-on-reload branch August 27, 2026 19:49
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.

2 participants