cron-health-check.md
702 Bytes
从 Cron Job 检查 WeChat Viewer 是否在线
端口陷阱
WeChat Viewer 运行在 5001 端口(硬编码在 app.py)。任何健康检查必须用 5001,不能用 5005——用错端口会返回空响应,误判为 VIEWER_DOWN。
健康检查命令
HTTP_CODE=$(curl -s --max-time 5 -o /dev/null -w "%{http_code}" http://localhost:5001/ 2>/dev/null)
3xx(302 重定向到 /login)= Viewer 在线000或空 = Viewer 挂了
快速重启
cd ~/wechat-viewer && python3 -B app.py &
sleep 3
验证记录
- 2026-08-05 13:01:cron-scheduler 轮次中用 5005 做 health check,误报 VIEWER_DOWN。实际 viewer 在 5001 正常运行。