Automated health monitoring for the news-platform services on CT222, motivated by the bridge crash-loop incident (BIT-743) where 3,608 restarts went undetected until manual discovery. Health endpoints: - Bridge /health enhanced with optional ?checks=true for deep dependency probes (WordPress, Redis) and uptime reporting - Frontend /health.json added as Astro API route Monitoring infrastructure: - healthcheck.sh: periodic probe script with HTTP checks, systemd restart-count detection, cooldown logic, and Ntfy push alerting - news-healthcheck.timer: runs every 3 min (detection < 5 min) - [email protected]: OnFailure template for instant crash alerts - All three service units updated with OnFailure= directive - deploy.sh updated to install monitoring units and env file Paperclip-Agent: peter-spark Paperclip-Issue: BIT-744 Paperclip-Run: 405ab587-8b8b-4963-8867-0feb95a994e3
25 lines
829 B
Desktop File
25 lines
829 B
Desktop File
[Unit]
|
|
Description=News Platform — Immediate Failure Alert for %i
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
EnvironmentFile=/etc/news-platform/healthcheck.env
|
|
ExecStart=/bin/bash -c '\
|
|
NTFY_URL="${NTFY_URL:-}"; \
|
|
if [ -z "$NTFY_URL" ]; then \
|
|
echo "[alert] %i failed — no NTFY_URL configured, logging only"; \
|
|
exit 0; \
|
|
fi; \
|
|
AUTH=""; \
|
|
if [ -n "${NTFY_TOKEN:-}" ]; then AUTH="-H \"Authorization: Bearer $NTFY_TOKEN\""; fi; \
|
|
eval curl -fsS \
|
|
-H \"Title: %i crashed on $(hostname)\" \
|
|
-H \"Priority: urgent\" \
|
|
-H \"Tags: rotating_light\" \
|
|
$AUTH \
|
|
-d \"Service %i failed at $(date -u +%%Y-%%m-%%dT%%H:%%M:%%SZ). Check with: journalctl -u %i --since -5min\" \
|
|
\"$NTFY_URL\" || echo "[alert] Failed to send Ntfy notification"'
|
|
StandardOutput=journal
|
|
StandardError=journal
|
|
SyslogIdentifier=news-alert
|