Skip to content

Add build-mode --socket/--host flags and dedupe dev side-cars - #487

Closed
silviogutierrez wants to merge 1 commit into
mainfrom
feature/dev-server-socket-and-sidecar-env
Closed

silviogutierrez wants to merge 1 commit into
mainfrom
feature/dev-server-socket-and-sidecar-env

Conversation

@silviogutierrez

Copy link
Copy Markdown
Owner

Build mode serves Django directly, so the dev server's listener is ours to choose. Two flags plus a side-car fix.

--socket

Bind a unix socket instead of TCP. A reverse proxy in front of a preview/staging deploy wants a stable address, but the dev port is allocated per checkout, so the proxy can't know it at config time — today that gap needs a forwarding side-car per deploy. A socket removes the bridge entirely. A crashed run's leftover socket file is cleared once we confirm nothing is accepting on it, and it's unlinked on exit.

--host

Widen the bind past loopback, so the dev server is reachable from another machine without a forwarding side-car. Independent of the socket work.

Both are build-mode only and exit with a clear message otherwise (in vite mode the user-facing listener is Vite's express server, and uvicorn is an implementation detail behind it). --socket + --port is rejected as mutually exclusive. When a socket is bound, DJANGO_PORT is not exported (nothing listens on a port).

Dedupe dev side-cars

parse_processes() collapses duplicate lines in REACTIVATED_DEV_PROCESSES (first wins, order preserved). The variable is exported, so a project's env setup that appends its own lines re-appends them on every nested shell entry — which is why a project ends up clearing the variable, and clearing is what silently drops a side-car an outer caller injected. With dedupe, a project can seed from the inherited value instead.

Tests / verification

  • New tests/dev_procs.py: parse_processes (incl. the inherited-line case) and is_socket_serving across absent / stale / live.
  • Full server suite: 124 passed, 2 skipped; ruff check + format clean.
  • The uds wiring is proven end to end: the same uvicorn Config the CLI now builds bound an AF_UNIX socket (uds wins over host/port), is_socket_serving reported True, and a request over the socket returned HTTP 200.

Pre-merge check worth doing: a full reactivate --build --socket against development/ was not run (that app's node_modules/reactivated isn't linked in a fresh clone, so build.client 404s before the server starts — a pre-existing bootstrap gap, unrelated). The uds mechanism the flag depends on is covered above.

🤖 Generated with Claude Code

Build mode serves Django directly, so the listener is ours to choose.
A reverse proxy in front of a preview or staging deploy wants a stable
address, but DEBUG_PORT is allocated per checkout — so the proxy cannot
know it at config time. Today that gap is bridged by a forwarding
side-car per deploy, wired through REACTIVATED_DEV_PROCESSES.

--socket binds a unix socket instead of TCP, which removes the bridge
entirely, and --host widens the bind past loopback so the server is
reachable from another machine without a forwarding side-car. Both are
build-mode only and say so: in vite mode the user-facing listener is
Vite's express server, and uvicorn is an implementation detail behind
it. A crashed run's leftover socket file is cleared once we confirm
nothing is accepting on it, and the socket is unlinked on exit.

Side-cars gain a second variable and duplicate collapsing, which
together make injection safe without asking projects to be careful.
REACTIVATED_DEV_PROCESSES is exported, so it crosses shell boundaries:
a project that appends its own lines re-appends them on every nested
shell entry, and clearing the variable is the obvious way to stay
idempotent. That clearing is also what silently drops a side-car an
outer caller injected.

So a caller — a preview supervisor, a container entrypoint — now uses
REACTIVATED_DEV_PROCESSES_EXTRA, which no project writes. Projects keep
the plain single-variable API and may append, clear or rebuild it
freely; an injected side-car survives regardless. Duplicates are
collapsed across both, so a project that does seed from the inherited
value spawns one process rather than two. The framework absorbs the
problem instead of every consumer having to avoid it.
@github-actions

Copy link
Copy Markdown

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA. If applicable, I have secured permission from my employer.


You can retrigger this bot by commenting recheck in this Pull Request

@silviogutierrez

Copy link
Copy Markdown
Owner Author

Superseded by #488, which carries these commits (re-authored so the CLA passes) plus the NewType schema fix. Closing.

@silviogutierrez
silviogutierrez deleted the feature/dev-server-socket-and-sidecar-env branch August 16, 2026 03:57
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants