部署:重写 deploy/README(凭据/备份/清单),compose 透传腾讯凭据,health 自报 OCR 状态

This commit is contained in:
dev
2026-11-23 09:50:52 +08:00
parent 59e82b922a
commit c4e26051e3
5 changed files with 161 additions and 46 deletions
+15 -2
View File
@@ -23,7 +23,7 @@ from pathlib import Path
from urllib.parse import parse_qs, urlparse
from . import db as dbm
from . import kp_graph, qr
from . import kp_graph, ocr_budget, qr, tencent_ocr
from . import scanflow, services as svc
from .services import ApiError
@@ -103,8 +103,21 @@ def health(ctx: Ctx, **kw):
svc.sweep_uploads(ctx.conn) # 上传目录按 90 天清,内部自己限每天一次
except Exception:
pass
# 上线自查用:OCR 凭据配没配、这个月还剩多少次、缓存开没开。
# 故意不暴露密钥本身,只说「有没有」。
try:
ocr_state = {
"configured": tencent_ocr.available(),
"mode": tencent_ocr.mode(),
"cache": os.environ.get("OCR_CACHE", "") not in ("0", "false", "no", "off"),
"used": ocr_budget.used(),
"limit": ocr_budget.limit() or None,
"remaining": ocr_budget.remaining(),
}
except Exception:
ocr_state = {"configured": None}
return {"ok": True, "service": "qingling-primary", "version": "1.2.0", "time": dbm.now(),
"wx_mode": svc.wechat.mode(), "routes": len(ROUTES)}
"wx_mode": svc.wechat.mode(), "routes": len(ROUTES), "ocr": ocr_state}
@route("POST", "/api/auth/wx-login", auth="none")