ops: portable launcher — clone anywhere, ./chamber up (cuda autodetect, cpu fallback, site+relay one process)
deploy-railway / relay (push) Skipped

This commit is contained in:
pierre committed 2026-10-30 15:33:42 +03:00
1 parent f8177fc979
commit bbfcdd5480
2 files changed
+153

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
"""Portable chamber launcher: original relay app at /chamber, static site at /.
One process, one port — clone anywhere, `./chamber up`, get the full lab.
The upstream live/server.py stays unmodified; this only mounts it.
"""
import os
import sys
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)
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)
app.mount("/chamber", server.app)
if SITE.exists():
app.mount("/", StaticFiles(directory=str(SITE), html=True), name="site")
else:
app.mount("/", server.app) # no site dir: relay everywhere
if __name__ == "__main__":
import uvicorn
port = int(os.environ.get("CHAMBER_PORT", "8000"))
uvicorn.run(app, host=os.environ.get("CHAMBER_HOST", "127.0.0.1"), port=port)