Label reflex child processes in `ps` (e.g. `reflex run [compiler]`)
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
- #7655 von @Akarshkushwaha — ohne Merge geschlossen
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- Ein halber Tag
- Anfängerfreundlichkeit
- 72/100
- Issue-Typ
- Feature
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- python
- Bereich
- backend, developer-experience
Rechercherichtung
Start with _compile_app_worker in reflex/reflex.py, the Granian(...) constructions in reflex/utils/exec.py, and the dependency in pyproject.toml. Add process titles for the compiler and relevant Granian services, then check uv run python scripts/check_min_deps.py and add the proposed helper tests, news fragment, and deployment documentation sentence. Done when child processes show their roles in process listings and every Granian construction passes an explicit title.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the Enhancement you want
When reflex run starts, it spawns several child processes (the compiler worker, the Granian backend supervisor and its workers). They inherit the parent's command line, so ps auxww shows a wall of identical reflex run --frontend-port=3000 ... lines (or, with the spawn/forkserver start method, an unreadable python -c from multiprocessing.spawn import spawn_main; ... line). It would be much easier to tell them apart if each child set its own process title with a suffix naming its role:
root 5833 /usr/local/bin/python /usr/local/bin/reflex run --frontend-port=3000 --backend-port=8000 --loglevel=error
root 5853 /usr/local/bin/python /usr/local/bin/reflex run [compiler]
root 5916 /usr/local/bin/bun run dev
root 5917 node /home/user/app/.web/node_modules/.bin/react-router dev --host
root 5924 /usr/local/bin/python /usr/local/bin/reflex run [backend]
root 5925 /usr/local/bin/python /usr/local/bin/reflex run [backend] worker-1
- Which feature do you want to improve?
reflex run/reflex run --env prodprocess management. - What is the benefit? Debugging and ops:
ps,top,htopand container process views immediately show which process is the compiler, the backend supervisor, or a worker, and which one is burning CPU or memory.
Where the processes come from
| Child | Spawned from | Mechanism | What ps shows today |
|---|---|---|---|
| Compiler | reflex/reflex.py _compile_app |
ProcessPoolExecutor(max_workers=1); start method is fork, forkserver or spawn depending on platform / REFLEX_BACKEND_START_METHOD |
fork: parent's full command line; spawn/forkserver: python -c from multiprocessing.spawn ... |
| Backend supervisor + workers (dev and prod) | reflex/utils/exec.py run_granian_backend, run_granian_backend_prod, run_frontend_prod |
Granian Server.serve(), workers via multiprocessing |
same as above, by start method |
| Backend, legacy uvicorn/gunicorn path (only when uvicorn is installed) | run_uvicorn_backend, run_uvicorn_backend_prod |
uvicorn reload supervisor (spawn) or python -m gunicorn |
python -c ... / python -m gunicorn ... |
| Frontend dev server | exec.py run_process_and_launch_url via processes.new_process |
subprocess.Popen(["bun", "run", "dev"]); bun then spawns node .../react-router dev --host |
already self-describing |
Proposed implementation
Granian already supports this. granian.server.Server(process_name=...) sets the supervisor's title to process_name and each worker's title to f"{process_name} worker-{n}". It only needs the granian[pname] extra, which is the setproctitle package (prebuilt wheels for every CPython reflex supports, including 3.14). Without the extra, passing process_name raises ConfigurationError, so the dependency has to be unconditional rather than optional.
- In
pyproject.toml, changegranian[reload] >=2.7.4togranian[reload,pname] >=2.7.4. Check thatuv run python scripts/check_min_deps.pystill passes. - Add a small helper in
reflex/utils/processes.py(orexec.py), e.g.set_process_title(label: str), that builds a title such asf"{sys.executable} {Path(sys.argv[0]).name} run [{label}]"and callssetproctitle.setproctitle(...). Keep thesetproctitleimport inside this one helper. Note thatsetproctitlereplaces the whole title rather than appending, and under spawn the child's own argv is the-cbootstrap line, so constructing the title from scratch is the right approach for every start method. - Call the helper at the top of
_compile_app_workerinreflex/reflex.pywith the labelcompiler. This function already runs inside the child. (Verified: with this call, fork, forkserver and spawn all show.../python3 reflex run [compiler].) - Pass
process_name=to the threeGranian(...)constructions inreflex/utils/exec.py: the dev backend (ParentBoundGranianinrun_granian_backend),run_granian_backend_prod, and the prod static frontend server (run_frontend_prod, which callsrun_granian_backend_prodwith its ownapp_target). Use labels likebackendandfrontend; Granian then names workersreflex run [backend] worker-1. - Add a news fragment (
news/+process-titles.feature.md), a unit test for the helper and for_compile_app_worker(monkeypatchsetproctitle), and a sentence in the deployment docs mentioning thatpsshows labeled processes.
Important: once setproctitle is importable, Granian's default title also changes, to granian asgi 0.0.0.0:8000 app:module for the supervisor and ... worker-1 for workers. So every Granian(...) call in reflex must pass process_name, otherwise the output changes in an unintended way.
Out of scope / caveats
- bun / node frontend processes cannot be labeled from outside.
exec -a "bun [frontend]" bun run devdoes change argv[0] of the bun process on POSIX, but it needs a shell wrapper, does nothing for thenode react-router devgrandchild (which is the one that actually uses CPU), and has no Windows equivalent.bun run devis already recognisable, so leave it alone. Appending a literal[frontend]argument is not safe either, sincebun run devforwards extra arguments to the script. - The legacy uvicorn dev reload worker's only reflex-controlled entry point is the app factory, so labeling it would be hacky. Skip it. gunicorn in prod labels its own master and workers once
setproctitleis installed. prctl(PR_SET_NAME)only changes the 15-charactercommfield, not theargscolumn, so it is not a substitute.- macOS:
setproctitleworks andpsshows the title; Activity Monitor keeps the original name. - Windows:
setproctitleonly sets the console window title; the command line in Task Manager is unchanged. Harmless, no gating needed, but no visible benefit. - On Linux the title is written over the original argv + environ block and is truncated beyond it.
reflex run [compiler]is shorter than any realistic original command line, so this is not a practical concern.
Estimated effort: about half a day including tests.
- Vorherrschende Sprache
- Python
- Sterne
- 29k
- Forks
- 1.8k
- Ø Merge
- 3 T. 5 Std.
- Gemergte PRs (30 T.)
- 182
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus reflex-dev/reflex
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 78/100
reflex-dev/reflex#8026 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Kept env.py failure: the "move it aside" hint is dropped and a full traceback is logged when alembic.ini uses a relative script_locationEvtl. vergeben @MaiAditya hat das vor 13 Tagen übernommen. Offenbug release-train
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
reflex-dev/reflex#7856 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
0.9.12 changelog follow-ups: the #7132 "_get_was_touched" entry describes unreachable behaviour, #7115's hasattr/getattr change is undocumented, #7131's wordingEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offenrelease-train
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
reflex-dev/reflex#7260 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
ClientStateVar: a component that mounts while the value is non-default never re-renders on the push back to the defaultEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
reflex-dev/reflex#6823 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
documentation upstream
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
reflex-dev/reflex#6436 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in reflex-dev/reflex
Ähnliche Issues
-
todo
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
tonybaloney/CSnakes#864 ·
-
infra
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
libre-embedded/svgen#72 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Genesis-Embodied-AI/genesis-world#3950 ·
Maintainer antworten meist innerhalb von 1 Tag
-
accessibility
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag