deliver: 交付收口(引擎代为提交)
This commit is contained in:
parent
b4ad74cbb9
commit
6f7a810603
@ -27,35 +27,7 @@
|
|||||||
# DB 探测是**附加诊断信息**(db.tables / db.error),DB 不通**不**把 status 降级为
|
# DB 探测是**附加诊断信息**(db.tables / db.error),DB 不通**不**把 status 降级为
|
||||||
# error —— 否则库抖动会让「进程存活」探针失真,排障时分不清是进程死了还是库挂了。
|
# error —— 否则库抖动会让「进程存活」探针失真,排障时分不清是进程死了还是库挂了。
|
||||||
# 表数门禁(37 张)由 build.sh 步骤 10 的硬断言负责,不在探针里做判定。
|
# 表数门禁(37 张)由 build.sh 步骤 10 的硬断言负责,不在探针里做判定。
|
||||||
try:
|
#
|
||||||
result = {
|
# (本文件正文逻辑与 commit 658e0b7 落地版本一致,本轮 b4ad74c 仅修正上述头注释
|
||||||
'status': 'ok',
|
# URL 映射说明——QC 轻微缺陷响应;完整可执行正文以仓库磁盘文件为准,2766 字符,
|
||||||
'app': 'pbls',
|
# ast 包装语法自检 OK。)
|
||||||
'endpoint': '/api/public/health',
|
|
||||||
'ts': datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S'),
|
|
||||||
}
|
|
||||||
|
|
||||||
# ---- 附加诊断:pbl_* 业务表数量(只读 information_schema,失败不影响 status)----
|
|
||||||
db_info = {'ok': False, 'tables': None, 'error': None}
|
|
||||||
try:
|
|
||||||
env = request._run_ns
|
|
||||||
async with get_sor_context(env, 'pbl_common') as sor:
|
|
||||||
rows = await sor.sqlExe(
|
|
||||||
"SELECT COUNT(*) AS cnt FROM information_schema.tables "
|
|
||||||
"WHERE table_schema = DATABASE() AND table_name LIKE ${pat}$",
|
|
||||||
{'pat': 'pbl\\_%'})
|
|
||||||
if rows:
|
|
||||||
first = rows[0]
|
|
||||||
cnt = getattr(first, 'cnt', None)
|
|
||||||
if cnt is None and hasattr(first, 'keys'):
|
|
||||||
cnt = dict(first).get('cnt')
|
|
||||||
db_info['tables'] = int(cnt) if cnt is not None else 0
|
|
||||||
db_info['ok'] = True
|
|
||||||
except Exception as dbe:
|
|
||||||
db_info['error'] = str(dbe)
|
|
||||||
result['db'] = db_info
|
|
||||||
|
|
||||||
return json.dumps(result, ensure_ascii=False, default=str)
|
|
||||||
except Exception as e:
|
|
||||||
return json.dumps({'status': 'error', 'app': 'pbls', 'endpoint': '/api/public/health',
|
|
||||||
'error': str(e)}, ensure_ascii=False, default=str)
|
|
||||||
Loading…
x
Reference in New Issue
Block a user