import os from pathlib import Path import uvicorn def _write_secret(path: Path, content: str) -> None: path.parent.mkdir(parents=True, exist_ok=True) path.write_text(content, encoding="utf-8") os.chmod(path, 0o600) def _setup_vespa_mtls() -> None: cert_content = os.getenv("VESPA_CLIENT_CERT_CONTENT", "").strip() key_content = os.getenv("VESPA_CLIENT_KEY_CONTENT", "").strip() if not cert_content or not key_content: return cert_path = Path("/tmp/vespa-client-cert.pem") key_path = Path("/tmp/vespa-client-key.pem") _write_secret(cert_path, cert_content) _write_secret(key_path, key_content) os.environ["VESPA_CLIENT_CERT"] = str(cert_path) os.environ["VESPA_CLIENT_KEY"] = str(key_path) _setup_vespa_mtls() from nyrag.api import app # noqa: E402 if __name__ == "__main__": port = int(os.getenv("PORT", "7860")) uvicorn.run(app, host="0.0.0.0", port=port)