Skip to content

fix(worker): clear error on a taken dashboard port; ordered setup output - #42

Merged
halfaipg merged 1 commit into
mainfrom
fix/setup-port-and-output
Oct 3, 2026
Merged

halfaipg merged 1 commit into
mainfrom
fix/setup-port-and-output

Conversation

@halfaipg

@halfaipg halfaipg commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #40, from verifying v0.3.10 on a 2x RTX 6000 vLLM host where a second worker ran next to the live one.

Problems

  • Taken dashboard port: in console mode the worker runs inside the dashboard app. When port 7861 was already in use, uvicorn failed to bind, the worker task was cancelled and the process exited, after --setup had already printed ok.. The readiness probe also connected to the other worker's dashboard, so the log said Dashboard: http://localhost:7861 for a server this process never started.
  • Jumbled --setup output: stdout is block-buffered when it is not a TTY (pipes, nohup, journald), so ok. and the setup summary printed after the worker's log lines. That made it look as if the worker started before setup finished.

Changes

  • cli.main checks the dashboard port before starting in console mode. If it's taken, it exits 1 with Error: dashboard port 7861 is already in use … grid-inference-worker --port 7862.
  • The desktop window (GUI) keeps the existing behaviour and opens the already-running dashboard, so a second double-click doesn't vanish silently.
  • The probe uses SO_REUSEADDR like uvicorn (not on Windows), so a TIME_WAIT socket from a just-restarted service doesn't count as "in use".
  • stdout and stderr are line-buffered at startup.
  • DOX: inference_worker/AGENTS.md and tests/AGENTS.md updated.

Verification

  • pytest tests/ passes: 171 passed, 1 skipped, including 4 new tests (real bound socket, console exit with hint and nothing started, GUI still opens the existing dashboard, line buffering).
  • node --test tests/onboarding-ui.test.mjs passes: 32/32.
  • Live run with the real worker holding :7861 and stdout piped:
      Checking http://127.0.0.1:8000… vLLM.
      Validating flash-next… ok.
      ...
      Saved to /home/aipg/grid-worker-src/.env
      Error: dashboard port 7861 is already in use, most likely by another worker on this machine.
      Start this worker on a free port: grid-inference-worker --port 7862
    
    Exit code 1.

🤖 Generated with Claude Code

Feedback from a second worker on the same 2x RTX 6000 host:

- Console mode checks the dashboard port before starting. A taken port
  used to cancel the worker and exit after setup printed "ok" (and the
  readiness probe found the other worker's dashboard). It now exits 1
  with a --port hint. The desktop window still opens the running
  dashboard.
- stdout/stderr are line-buffered, so --setup output no longer
  interleaves with worker log lines in pipes, nohup, or journald.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@halfaipg
halfaipg merged commit dfed0d1 into main Oct 3, 2026
20 checks passed
@halfaipg
halfaipg deleted the fix/setup-port-and-output branch October 3, 2026 05:43
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