部署:重写 deploy/README(凭据/备份/清单),compose 透传腾讯凭据,health 自报 OCR 状态
This commit is contained in:
+15
-2
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user