Skip to content

ttyd processes die when orchestration runner exits — need setsid detachment #145

@lukstafi

Description

@lukstafi

Problem

startTtyd() in src/adapters/tmux-adapter.ts spawns ttyd via Bun.spawn() with .unref(), but no setsid. The ttyd processes remain children of the orchestration runner. When the runner exits or is killed, all ttyd processes for that slot die too, causing "refused to connect" in the dashboard terminals tab.

This is the same class of issue fixed for the runner itself (setsid wrap in slot start). The fix should apply the same setsid pattern to ttyd spawning.

Evidence

After migrating federation controller to mac-studio, all per-slot ttyd processes (ports 7681-7692) died while runners stayed alive. Only the Mag ttyd (port 7679) survived. slot resume re-creates them but they die again on next runner restart.

Fix

Wrap ttyd spawn with setsid in startTtyd() (~line 237):

const proc = Bun.spawn(
  ["setsid", "ttyd", "--writable", "--port", String(port), "tmux", "attach", "-t", target],
  { stdin: "ignore", stdout: "ignore", stderr: "ignore" },
);

Related

  • startTtyd() in src/adapters/tmux-adapter.ts:228-243
  • Slot resume re-creation in src/slots/index.ts:894-906 (same pattern, also needs setsid)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions