This commit is contained in:
wuyongtao
2026-08-03 17:34:23 +08:00
22 changed files with 766 additions and 219 deletions

View File

@@ -376,9 +376,9 @@ class PlatformStore:
pool_kwargs = {
"connect_timeout": 5,
"keepalives": 1,
"keepalives_idle": 30,
"keepalives_interval": 10,
"keepalives_count": 5,
"keepalives_idle": 10,
"keepalives_interval": 5,
"keepalives_count": 3,
}
self._pool = ConnectionPool(
conninfo=self.database_url,
@@ -3115,12 +3115,24 @@ class PlatformStore:
}
def health_metrics(self) -> dict[str, float]:
# Health checks must stay lightweight. The Docker healthcheck and page
# refresh probes should not wait on dashboard/GPU/database aggregation.
# 轻量健康检查:采集真实 CPU/内存/磁盘使用率
# 用于顶部栏快速展示与 Docker 健康检查。
try:
import psutil
# cpu_percent(interval=None) 首次调用返回 0需要短暂采样
cpu_percent = float(psutil.cpu_percent(interval=0.1))
memory_percent = float(psutil.virtual_memory().percent)
# Windows 兼容:尝试当前盘符
try:
disk_percent = float(psutil.disk_usage('/').percent)
except Exception:
disk_percent = float(psutil.disk_usage('C:\\').percent)
except Exception:
cpu_percent = memory_percent = disk_percent = 0.0
return {
"cpu_percent": 0.0,
"memory_percent": 0.0,
"disk_percent": 0.0,
"cpu_percent": round(cpu_percent, 1),
"memory_percent": round(memory_percent, 1),
"disk_percent": round(disk_percent, 1),
}
def queue(self) -> list[dict[str, Any]]: