Add build-mode --socket/--host flags and dedupe dev side-cars - #487
Closed
silviogutierrez wants to merge 1 commit into
Closed
silviogutierrez wants to merge 1 commit into
silviogutierrez wants to merge 1 commit into
Conversation
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.
|
CLA Assistant Lite bot: 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 |
Owner
Author
|
Superseded by #488, which carries these commits (re-authored so the CLA passes) plus the NewType schema fix. Closing. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Build mode serves Django directly, so the dev server's listener is ours to choose. Two flags plus a side-car fix.
--socketBind 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.
--hostWiden 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+--portis rejected as mutually exclusive. When a socket is bound,DJANGO_PORTis not exported (nothing listens on a port).Dedupe dev side-cars
parse_processes()collapses duplicate lines inREACTIVATED_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
tests/dev_procs.py:parse_processes(incl. the inherited-line case) andis_socket_servingacross absent / stale / live.Configthe CLI now builds bound anAF_UNIXsocket (uds wins over host/port),is_socket_servingreported True, and a request over the socket returned HTTP 200.Pre-merge check worth doing: a full
reactivate --build --socketagainstdevelopment/was not run (that app'snode_modules/reactivatedisn't linked in a fresh clone, sobuild.client404s before the server starts — a pre-existing bootstrap gap, unrelated). The uds mechanism the flag depends on is covered above.🤖 Generated with Claude Code