-
Notifications
You must be signed in to change notification settings - Fork 143
chore: fix local dev server port assignments #1635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d63640e
chore: fix local dev server port assignments
michaelmagan 16a75fa
chore: use 826x ports for local dev
CharlieHelps 2224101
chore: fail fast if dev ports are in use
CharlieHelps 8cc7ae0
chore: use node for dev-local port checks
CharlieHelps cfb4927
chore: clarify dev-local port check
CharlieHelps dadc203
chore: use npx for supabase commands
CharlieHelps 0019a72
chore: document npx supabase usage
CharlieHelps 537fb35
chore: use JSON output for Supabase status
CharlieHelps 3b6cffb
chore: check Supabase status via JSON
CharlieHelps File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| #!/bin/bash | ||
| # Start full local dev environment with file upload support | ||
| # Usage: ./scripts/dev-local.sh | ||
|
|
||
| set -e | ||
|
|
||
| echo "Starting local dev environment..." | ||
|
|
||
| echo "Checking that ports 8260-8263 are free (web/api/showcase/docs)..." | ||
| if ! command -v node >/dev/null 2>&1; then | ||
| echo "Node.js is required to run this script. Please install Node and try again." | ||
| exit 1 | ||
| fi | ||
|
|
||
| for port in 8260 8261 8262 8263; do | ||
| if ! node - "$port" <<'NODE' | ||
| const net = require("node:net"); | ||
|
|
||
| // Exit 0 if the port on 127.0.0.1 is available, 1 otherwise. | ||
| const portArg = process.argv[2]; | ||
| const port = Number.parseInt(portArg, 10); | ||
| if (!Number.isInteger(port) || port <= 0 || port > 65535) { | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const server = net.createServer(); | ||
| server.unref(); | ||
|
|
||
| server.on("error", () => { | ||
| process.exit(1); | ||
| }); | ||
|
|
||
| server.listen({ host: "127.0.0.1", port }, () => { | ||
| server.close(() => { | ||
| process.exit(0); | ||
| }); | ||
| }); | ||
| NODE | ||
| then | ||
| echo "Port ${port} is already in use. Stop the process using it, then re-run this script." | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| # 1. Start Postgres (if not running) | ||
| if ! docker ps | grep -q tambo_postgres; then | ||
| echo "Starting Postgres..." | ||
| docker compose --env-file docker.env up postgres -d | ||
| sleep 3 | ||
| fi | ||
lachieh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # 2. Start Supabase (if not running) | ||
| # Use npx so developers don't need a globally installed Supabase CLI. | ||
| if ! npx --yes supabase status -o json 2>/dev/null | node <<'NODE' | ||
| const fs = require("node:fs"); | ||
|
|
||
| const input = fs.readFileSync(0, "utf8").trim(); | ||
| if (input.length === 0) { | ||
| process.exit(1); | ||
| } | ||
|
|
||
| let data; | ||
| try { | ||
| data = JSON.parse(input); | ||
| } catch { | ||
| process.exit(1); | ||
| } | ||
|
|
||
| if (data === null || typeof data !== "object" || Array.isArray(data)) { | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const apiUrl = data["API_URL"]; | ||
| // `supabase status -o json` emits connection info keyed by env var names. | ||
| // Treat a non-empty `API_URL` as the signal that the local stack is running. | ||
| process.exit(typeof apiUrl === "string" && apiUrl.length > 0 ? 0 : 1); | ||
| NODE | ||
| then | ||
| echo "Starting Supabase..." | ||
| npx --yes supabase start | ||
| fi | ||
|
|
||
| # 3. Run migrations (idempotent) | ||
| echo "Running migrations..." | ||
| DATABASE_URL="postgresql://postgres:postgres@localhost:5433/tambo" npm run db:migrate -w packages/db 2>/dev/null || true | ||
|
|
||
lachieh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # 4. Start all dev servers | ||
| echo "" | ||
| echo "Starting dev servers..." | ||
| echo " Web: http://localhost:8260" | ||
| echo " API: http://localhost:8261" | ||
| echo " Showcase: http://localhost:8262" | ||
| echo " Docs: http://localhost:8263" | ||
| echo " Supabase: http://127.0.0.1:54423" | ||
| echo "" | ||
|
|
||
| npm run dev:cloud:full | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.