feat(admin): run proxy as multi-worker uvicorn via app factory (#1191)#1194
Merged
zhongwen666 merged 1 commit intoJul 1, 2026
Merged
Conversation
Proxy pods can now run multiple uvicorn workers instead of one process per pod. Move argv parsing into main() and set env vars before workers spawn, convert the module-level app into a create_app() factory so uvicorn can build one app per worker, and resolve the worker count via resolve_workers (admin/local/test/dev forced to 1; proxy uses --workers or ROCK_PROXY_WORKERS, else 1). Integration conftest switches from argv to env vars to match create_app(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 1, 2026
xieyang0827
approved these changes
Jul 1, 2026
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.
closes #1191
Stack 1/3 — base for the log-append and httpx-reuse PRs. Merge this first.
Split from the original combined proxy multi-core PR (#1147). This PR only introduces multi-worker support:
create_app()app factory +_include_routers(), so uvicorn can build one app per worker viafactory=True._parse_args()/main()refactor: env + role set as env vars before workers spawn (lifespan/create_appread them instead of argv).resolve_workers()pure helper (rock/utils/worker.py): admin/local/test/dev → 1; proxy →--workers>ROCK_PROXY_WORKERS> 1.ROCK_PROXY_WORKERSenv var;uvicorn.run(..., workers=workers).create_app().Tests:
tests/unit/utils/test_worker.py,tests/unit/admin/test_create_app_routes.py.