Skip to content

Reap all workspace port listeners on archive and server boot#2002

Merged
maebeale merged 1 commit into
mainfrom
maebeale/tripoli-v2
Jul 17, 2026
Merged

Reap all workspace port listeners on archive and server boot#2002
maebeale merged 1 commit into
mainfrom
maebeale/tripoli-v2

Conversation

@maebeale

Copy link
Copy Markdown
Collaborator

🤖 suggested review level: 3 Read 📖 small POSIX-sh port-cleanup change in two conductor scripts, no app logic

What is the goal of this PR and why is this important?

  • The archive hook killed only the first listener on each workspace port via a quoted kill "$pid", which passed lsof's newline-joined multi-PID output as a single argument and silently failed.
  • Puma cluster workers (and bin/vite dev's esbuild children) were left orphaned — still bound to the port — and collided with the next workspace to recycle the block. This is the same leak we just fixed in festilite.

How did you approach the change?

  • Added a free_ports reaper to both bin/conductor-archive and bin/conductor-server: word-split the PID list, SIGTERM each, then SIGKILL survivors after a grace beat.
  • conductor-server now frees PORT/PORT+36 on boot too, so a ghost from a crashed session self-heals instead of failing to bind.

Anything else to add?

  • POSIX-sh only; sh -n clean. No Ruby/app changes.

The archive hook killed only the first listener on each workspace port with a
quoted `kill "$pid"`, which passed lsof's newline-joined multi-PID output as
a single argument and silently failed. Puma cluster workers (and `bin/vite dev`'s
esbuild children) were left orphaned, staying bound to the port and colliding
with the next workspace to recycle the block. Word-split the PID list, SIGTERM
each, then SIGKILL survivors, and free the same ports on conductor-server boot so
a ghost from a crashed session self-heals instead of failing to bind.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 17, 2026 14:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

@maebeale
maebeale marked this pull request as ready for review July 17, 2026 20:44
@maebeale
maebeale merged commit adccdd2 into main Jul 17, 2026
3 checks passed
@maebeale
maebeale deleted the maebeale/tripoli-v2 branch July 17, 2026 20: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