Stelle den Frontend-MVP und die v0.3-API auf develop bereit, damit Dev API und PWA zusammen deployen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
827e6a2a11
commit
b276758ee1
152 files changed
+25846
-34
No files matched your search
@@ -1,45 +0,0 @@
|
||||
from fastapi import APIRouter
|
||||
from fastapi.responses import JSONResponse
|
||||
from sqlalchemy import text
|
||||
|
||||
from alembic.config import Config
|
||||
from alembic.runtime.migration import MigrationContext
|
||||
from alembic.script import ScriptDirectory
|
||||
|
||||
from app.persistence.db import engine
|
||||
from app.settings import get_settings
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
def _alembic_at_head() -> bool:
|
||||
config = Config("alembic.ini")
|
||||
script = ScriptDirectory.from_config(config)
|
||||
with engine.connect() as connection:
|
||||
context = MigrationContext.configure(connection)
|
||||
return set(context.get_current_heads()) == set(script.get_heads())
|
||||
|
||||
|
||||
@router.get("/health/live")
|
||||
def live() -> dict[str, str]:
|
||||
return {"status": "ok"}
|
||||
|
||||
|
||||
@router.get("/health/ready", response_model=None)
|
||||
def ready() -> JSONResponse | dict[str, str]:
|
||||
settings = get_settings()
|
||||
try:
|
||||
with engine.connect() as connection:
|
||||
connection.execute(text("SELECT 1"))
|
||||
if not _alembic_at_head():
|
||||
return JSONResponse(
|
||||
{"status": "not_ready", "reason": "migration_behind_head"},
|
||||
status_code=503,
|
||||
)
|
||||
except Exception:
|
||||
return JSONResponse({"status": "not_ready", "reason": "database"}, status_code=503)
|
||||
return {
|
||||
"status": "ready",
|
||||
"environment": settings.environment,
|
||||
"engine_build": settings.engine_build,
|
||||
}
|
||||
Reference in new issue
Block a user