diff --git a/backend/main.py b/backend/main.py index 57f95ab..775ac51 100644 --- a/backend/main.py +++ b/backend/main.py @@ -28,6 +28,23 @@ app = FastAPI(title="Jellomator") app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"]) +@app.get("/healthz") +def healthz(): + return {"ok": True} + + +@app.get("/readyz") +def readyz(): + try: + with db() as c: + with c.cursor() as cur: + cur.execute("select 1 as ok") + cur.fetchone() + except Exception: + raise HTTPException(503, "Database not ready") + return {"ok": True} + + @contextmanager def db(): conn = pymysql.connect(