run.sh: auto-pick a free backend port for multi-instance dev#76
Open
logan-nc wants to merge 1 commit into
Open
run.sh: auto-pick a free backend port for multi-instance dev#76logan-nc wants to merge 1 commit into
logan-nc wants to merge 1 commit into
Conversation
Running the GUI from several checkouts collided: the backend was hardcoded to :8000, so the second `./run.sh` failed to bind and its GUI silently proxied to the first checkout's backend (stale data, no obvious error). Now the live path picks the first free port >= 8000 (Vite already auto-picks the GUI port) and wires VITE_API_BASE to it, so multiple repos just work. `main()` honors HOST/PORT env vars (default 127.0.0.1:8000); override with `PORT=NNNN ./run.sh`. Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.
Problem
Running the GUI from several checkouts at once collided. The backend was hardcoded to
:8000, so the second./run.shhit[Errno 48] address already in use, shut its backend down, and its GUI silently proxied to the first checkout's backend — showing stale data (e.g. a new device not appearing) with no obvious error.Fix (fully automatic — no manual port picking)
run.sh(live path) now picks the first free port ≥ 8000 and wiresVITE_API_BASEto it. Vite already auto-picks a free GUI port, so each repo's GUI talks to its own backend.service/app.py:main()honorsHOST/PORTenv vars (default127.0.0.1:8000). Override explicitly withPORT=NNNN ./run.sh.Result:
./run.shin repo A grabs 8000, repo B grabs 8001, etc. — no collisions, nothing to configure.Verified
magnetics-serviceinstances run simultaneously (PORT=8000andPORT=8001), both serving/api/devicesindependently.PORT) still binds:8000— single-instance behavior unchanged.Lane
Touches shared GUI tooling (
run.sh) + the service entry point — flagging Interfacers for review. Kept separate from the HBT-EP device PR (#72).🤖 Generated with Claude Code