Uptime Monitoring
The Cloudflare Worker that watches production uptime.
Uptime monitoring - Cloudflare Worker (health/)
A small Cloudflare Worker (health/src/index.js) runs independently, on Cloudflare's edge, unaffected by an outage on the actual server:
[triggers]
crons = ["*/5 * * * *"] # every 5 minutesEach run fetches https://dashboard.trickfirerobotics.com/api/health with a 10-second timeout and expects an ok response body. On failure, it waits 5 seconds and retries once (to avoid alerting on a single transient blip) before treating the dashboard as down. If still down, it posts a Discord embed - pinging a fixed set of Discord user IDs (PING_IDS), with the failure reason and a UTC timestamp - to a webhook URL stored as a Worker secret, never in source:
$ cd health
$ pnpm dlx wrangler deploy
$ pnpm dlx wrangler secret put DISCORD_WEBHOOK_URLThe Worker's fetch handler also responds to a direct HTTP request to the Worker's own URL, which is useful for triggering an out-of-schedule check while testing changes to the alerting logic. To change who gets pinged, edit PING_IDS in health/src/index.js and redeploy.