Files
Nexus/docs/changelog/2026-06-21-health-check-write-heartbeat.md
2026-07-08 22:31:31 +08:00

32 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 健康检查写入 Redis 心跳
**日期**2026-06-21
## 变更摘要
批量「健康检查」在 SSH 探测后,将结果写入 `heartbeat:{server_id}`(与 Agent 心跳同结构),列表/宝塔模块可立即反映在线状态;任务结果 stdout 附带心跳时间。
## 动机
健康检查仅返回成功/失败,不更新 Redis,导致 `#/servers` 状态列与宝塔列表仍显示旧心跳或 unknown。
## 涉及文件
- `server/application/server_connectivity.py``write_ssh_health_heartbeat``normalize_ssh_probe_system_info`
- `server/application/services/server_batch_service.py``_run_health_check` 写心跳
- `server/application/services/server_service.py``check_all_servers` 同步写心跳
- `server/api/servers.py``has_heartbeat` 时无 Agent 也显示 offline/online
- `tests/test_server_connectivity.py``tests/test_server_status_field.py`
## 迁移 / 重启
需重启 API worker(后端部署)。
## 验证方式
```bash
.venv/bin/pytest tests/test_server_connectivity.py tests/test_server_status_field.py -q
```
生产:对离线机执行健康检查后刷新 `#/servers`,状态列应更新;批量任务详情 stdout 含「心跳 2026-…」。