chore(repo): dev サーバのポートをセット単位で自動割当し配線を追従させる (ADR-0030)#197
Merged
Conversation
別プロジェクト・別 worktree の dev サーバとポートが衝突すると vite が黙って
+1 ずれ、editor の /verify プロキシや VITE_API_URL が古いプロセスへつながる
問題への対応。
- npm run dev を scripts/dev.mjs 経由に: 既定 {5173,5174,8787} が埋まって
いたらセットごと +10 で空きを探索 (127.0.0.1 / ::1 の両方を検査)
- 決定ポートを EDITOR_PORT/VERIFY_PORT/WORKERS_PORT で各サーバへ注入し、
editor の /verify プロキシと VITE_API_URL (ローカル既定時のみ) を追従
- ランチャー割当時は strictPort: true で黙認ずれを禁止 (探索との race で
衝突しても即失敗し、再実行で次の空きセットへ)
- 個別起動 (dev:editor 等) は従来挙動のまま
- concurrently に names/色を付与し、起動バナーで実 URL を明示
- CONTRIBUTING の「併用するときはポートを変える」手動運用を置換
Closes #196
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🚀 Preview Deployment
Deployed from commit 48c63d4 |
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.
目的
別プロジェクト (例: subimage) や別 worktree の dev サーバがポートを占有していると、vite が黙って +1 ずつずれ、editor の
/verifyプロキシ (5174 固定) やVITE_API_URL(8787 固定) がエラーも出さずに古い残骸プロセスや別物へつながる。実際に「5173 を別プロジェクトに取られ、npm run devすると verify ばかり目に付く」混乱が発生した。複数サービスの同時デバッグを無調整で共存させる。Closes #196 / 設計判断は ADR-0030
変更点
scripts/dev.mjs(新規):npm run devの起動ランチャー。既定セット {editor 5173, verify 5174, workers 8787} の 3 ポートがすべて空くまでセットごと +10 (5183/5184/8797, …) で探索し (127.0.0.1 / ::1 の両方を検査、最大 10 セット)、決定値をEDITOR_PORT/VERIFY_PORT/WORKERS_PORTで各プロセスへ注入。concurrently に names (editor/verify/workers) と色を付け、起動バナーで実 URL を明示packages/editor/vite.config.ts:server.port//verifyプロキシ target を env から解決。VITE_API_URLは .env がローカル既定 (http://localhost:<port>) のときのみ実 workers ポートへ追従 (staging 等の外部 URL は非干渉)。ランチャー割当時はstrictPort: true(黙認ずれ禁止)packages/verify/vite.config.ts: 同様にserver.port+strictPortpackage.json:"dev"をnode scripts/dev.mjsに。個別起動 (dev:editor等) は従来どおり固定ポート + vite フォールバック変更しないもの: workers の CORS (dev は localhost ポート不問許可済み)、e2e (
E2E_EDITOR_PORT/E2E_WORKERS_PORTで既に可変・EDITOR_PORT未設定起動のため干渉なし)確認方法
実機 (5173 = 別プロジェクト、5174/5175/8787 = 既存 dev サーバが占有中) で検証済み:
curl http://localhost:5183/→<title>TypedCode</title>/:5184/→<title>TypedCode Verify</title>curl http://localhost:5183/verify/→<title>TypedCode Verify</title>(プロキシが 5184 へ追従)curl http://localhost:8797/health→{"status":"ok","environment":"development"}VITE_API_URLがhttp://localhost:8797に置換されていることを確認EDITOR_PORT=5183 npm run dev:editor→ フォールバックせず即失敗 (exit 1)npm run lint/npm run typecheck/ unit tests (editor 106, verify 14) すべて green🤖 Generated with Claude Code