监控里程碑
checkpoint-monitoring、monit;健康检查与告警。
监控里程碑
checkpoint-monitoring 要求为已部署应用配置 Monit:监控 CPU、内存、磁盘、网络、服务与进程可用性,并在异常时 告警或自动重启。路线图也提到 pm2 作 Node 进程守护;Java 栈可用 systemd + Monit 检查 HTTP 健康端点。Prometheus/Grafana 更重,Monit 适合 fsm-infra 单机或小型 EC2 的 第一道防线。节点详情见 fullstack-roadmap 与 /roadmaps/full-stack。
学习目标
- 对照 checkpoint-monitoring,在服务器上启用 Monit,覆盖 资源阈值 + 进程/HTTP 存活
- 理解 Monit 与 spring-boot-essentials Actuator
/actuator/health、Node pm2 的分工 - 将监控配置纳入 Git(Ansible template 或 docker-essentials sidecar 文档),与 github-actions-essentials 部署链衔接
路线图监控项
| 类型 | Monit 思路 |
|---|---|
| CPU / Memory / Disk | check system 与 if cpu > 80% for 5 cycles then alert |
| Network | 可选 check network 或依赖 HTTP 探活 |
| Service Availability | check process 匹配 pidfile 或 matching "java" |
| HTTP | check host 请求 http://localhost:8080/actuator/health |
官方提示:预制配置在 /etc/monit/conf-available,复制到 conf-enabled 后改端口与路径。
Spring Boot 示例片段
check process backend with pidfile /var/run/myapp.pid
start program = "/bin/systemctl start myapp"
stop program = "/bin/systemctl stop myapp"
if failed host 127.0.0.1 port 8080 protocol http
request "/actuator/health" for 3 cycles then restart
if 5 restarts within 5 cycles then timeout
spring-boot-essentials Actuator 课需先暴露 health;生产关闭敏感端点,仅内网 Monit 访问。
Node / 前端 SSR
pm2 ecosystem.config.js 管 cluster 与重启;Monit 可 check process pm2 或 HTTP 探活 Next 端口。静态 react-essentials 构建物由 nginx 提供时,Monit check nginx 进程 + 80 端口。