Harden runtime budgets: DB pool, CLI concurrency, timeouts, and metrics.

Add shared CLI budget/timeout with force-close, parallel port-traffic dispatch, unified shutdown, bounded audit queue, output/log caps, and /metrics probes.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-02 18:02:43 +08:00
parent 2068ce3d04
commit d56020d84c
23 changed files with 824 additions and 102 deletions

View file

@ -25,6 +25,9 @@ def health_live() -> dict[str, str]:
@router.get("/health/ready", status_code=200)
def health_ready(db: Session = Depends(get_db)) -> dict[str, Any]:
"""Readiness — DB plus scheduler deployment hint."""
from .cli_budget import cli_budget_status
from .db import db_pool_status
out: dict[str, Any] = {"status": "ok", "probe": "ready"}
try:
db.execute(sql_text("select 1"))
@ -36,6 +39,8 @@ def health_ready(db: Session = Depends(get_db)) -> dict[str, Any]:
"db": "down",
"error": str(exc)[:240],
}
out["db_pool"] = db_pool_status()
out["cli_budget"] = cli_budget_status()
inline = bool(getattr(settings, "run_inline_schedulers", True))
out["schedulers"] = {
"inline": inline,