fix(worker): mount /v1/worker/execute BEFORE add_routes()

In worker-mode the coordinator seam POST /v1/worker/execute was appended to
the route table AFTER prompt_server.add_routes() already mounted it (incl. the
SPA catch-all), so the POST route never registered — the catch-all answered
GET/HEAD and the worker got 405, every claimed render FAILED. Register the
worker routes before add_routes(). Verified: gpu:spark smoke render now
SCHEDULED→STARTED→COMPLETED via the gated seam.
This commit is contained in:
hanzo-dev
2026-07-21 15:33:32 -07:00
parent ce491d2848
commit cd92ea2a6c
+7 -4
View File
@@ -451,10 +451,10 @@ def start_studio(asyncio_loop=None):
cuda_malloc_warning()
setup_database()
prompt_server.add_routes()
hijack_progress(prompt_server)
# In worker mode, add worker execution routes and register with coordinator
# In worker mode, register the worker execution routes BEFORE add_routes() mounts
# the route table — otherwise POST /v1/worker/execute is appended after the SPA
# catch-all is already mounted and never registers, so the catch-all answers it
# (GET/HEAD only) and the coordinator seam 405s (no hidden-run hole, but no renders).
if args.worker_mode:
from middleware.worker_client import add_worker_routes, WORKER_TOKEN
# FAIL CLOSED: a worker box executes jobs the coordinator hands it over a
@@ -467,6 +467,9 @@ def start_studio(asyncio_loop=None):
logging.info("Worker mode enabled — worker_id=%s coordinator=%s",
args.worker_id, args.coordinator_url)
prompt_server.add_routes()
hijack_progress(prompt_server)
_worker_thread = threading.Thread(target=prompt_worker, daemon=True, args=(prompt_server.prompt_queue, prompt_server,))
_worker_thread.start()
# Exposed so /ready can gate on the render worker actually being alive: if this