ops: pin model revision in launcher env (offline-safe cache lookup)
deploy-railway / relay (push) Skipped

This commit is contained in:
pierre committed 2026-10-30 16:08:24 +03:00
1 parent 2ea582e95f
commit 834a544d2f
2 files changed
+21 -7

No files matched your search

+17 -3
View File
@@ -2,21 +2,35 @@
One process, one port — clone anywhere, `./chamber up`, get the full lab.
The upstream live/server.py stays unmodified; this only mounts it.
NOTE: Starlette Mounts do not propagate sub-app startup events, so
server.startup() (the model load) is invoked explicitly in the lifespan
below. Serving starts only after the model is ready.
"""
import asyncio
import os
import sys
from contextlib import asynccontextmanager
from pathlib import Path
ROOT = Path(__file__).resolve().parent
sys.path.insert(0, str(ROOT / "live"))
import server # noqa: E402 (loads the model at import — env vars go before this)
import server # noqa: E402 (loads env config at import; model loads in startup)
from fastapi import FastAPI # noqa: E402
from fastapi.staticfiles import StaticFiles # noqa: E402
SITE = ROOT / "site"
app = FastAPI(docs_url=None, redoc_url=None, openapi_url=None)
@asynccontextmanager
async def lifespan(app):
# server.startup() is sync and slow (model load); keep the loop alive
await asyncio.get_running_loop().run_in_executor(None, server.startup)
yield
app = FastAPI(docs_url=None, redoc_url=None, openapi_url=None, lifespan=lifespan)
app.mount("/chamber", server.app)
if SITE.exists():
app.mount("/", StaticFiles(directory=str(SITE), html=True), name="site")
@@ -27,5 +41,5 @@ else:
if __name__ == "__main__":
import uvicorn
port = int(os.environ.get("CHAMBER_PORT", "8000"))
port = int(os.environ.get("CHAMBER_PORT", "8484"))
uvicorn.run(app, host=os.environ.get("CHAMBER_HOST", "127.0.0.1"), port=port)