Skip to content

Commit f98bd7e

Browse files
ihabadhamclaude
andcommitted
docs: update worktree section — auto port detection is now zero-config
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bcc9a59 commit f98bd7e

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

docs/building-features/process-managers.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -334,27 +334,25 @@ wp-server: SERVER_BUNDLE_ONLY=true bin/shakapacker --watch
334334

335335
## Running Multiple Worktrees Simultaneously
336336

337-
If you use [git worktrees](https://git-scm.com/docs/git-worktree) to work on multiple branches in parallel, each worktree's `bin/dev` will conflict on the default ports (3000 for Rails, 3035 for webpack-dev-server).
337+
If you use [git worktrees](https://git-scm.com/docs/git-worktree) to work on multiple branches
338+
in parallel, `bin/dev` automatically detects and avoids port conflicts — no configuration needed.
338339

339-
Create a `.env` file in each worktree (gitignored by default in Rails apps). Both foreman and overmind read `.env` automatically on startup.
340+
When the default ports (3000 for Rails, 3035 for webpack-dev-server) are occupied, `bin/dev`
341+
scans for the next free pair and prints:
340342

341-
The generated `Procfile.dev` uses `${PORT:-3000}`, so setting `PORT` is enough for Rails. For the webpack dev server, Shakapacker reads `SHAKAPACKER_DEV_SERVER_PORT` natively on both the Ruby proxy and the webpack-dev-server JS sides — no `shakapacker.yml` changes needed.
342-
343-
**Worktree 1** — use defaults (no `.env` needed), or set explicitly:
344-
345-
```sh
346-
PORT=3000
347-
SHAKAPACKER_DEV_SERVER_PORT=3035
343+
```
344+
Default ports in use. Using Rails :3001, webpack :3036
348345
```
349346

350-
**Worktree 2 `.env`:**
347+
**To override ports manually**, create a `.env` file in the worktree (gitignored by default).
348+
A `.env.example` is generated by `rails g react_on_rails:install` as a reference:
351349

352350
```sh
353351
PORT=3001
354352
SHAKAPACKER_DEV_SERVER_PORT=3036
355353
```
356354

357-
A `.env.example` is generated by `rails g react_on_rails:install` as a starting point. Copy it to `.env` and adjust ports as needed.
355+
When `PORT` or `SHAKAPACKER_DEV_SERVER_PORT` are set, auto-detection is skipped entirely.
358356

359357
## See Also
360358

0 commit comments

Comments
 (0)