后端挂掉时邮件告警到 f1f3@qq.com。带去重防告警风暴,服务恢复时单独发 ✅。
| 文件 | 部署到 | 说明 |
|---|---|---|
health-monitor.sh |
/usr/local/bin/ |
主脚本 |
health-monitor.env.example |
/etc/health-monitor.env (改名) |
凭证模板 |
install.sh |
(服务器上跑一次) | 一键部署 |
# 1. 在本地打包
cd deploy-package/health-monitor && tar czf /tmp/health-monitor.tar.gz .
# 2. 上传到服务器
scp -P 22622 /tmp/health-monitor.tar.gz root@8.159.134.106:/tmp/
# 3. 服务器上安装
ssh -p 22622 root@8.159.134.106
cd /tmp && tar xzf health-monitor.tar.gz && cd health-monitor
# 4. 填 QQ 邮箱授权码
cp health-monitor.env.example /etc/health-monitor.env
vim /etc/health-monitor.env # 填入 QQ_AUTH_CODE
chmod 600 /etc/health-monitor.env
# 5. 部署
bash install.sh
/health 和 /api/navigation/configtail -f /var/log/health-monitor.log # 实时日志
pm2 list # PM2 进程状态
ss -lntp | grep 3100 # 端口监听
curl -sS http://127.0.0.1:3100/health # 直接验证
bash /usr/local/bin/health-monitor.sh # 手动跑一次
# 1. 暂停后端
pm2 stop server
# 2. 触发检测
bash /usr/local/bin/health-monitor.sh
bash /usr/local/bin/health-monitor.sh # 第二次会发邮件
# 3. 启动后端
pm2 start server
# 4. 触发恢复检测
bash /usr/local/bin/health-monitor.sh # 会发"已恢复"邮件
/var/lib/health-monitor/state — 记录连续失败次数 + 上次告警时间,去重逻辑