{ "name": "cron", "description": "Uptime monitor with cron checks, latency tracking, and live dashboard", "secrets": [], "capabilities": ["db"], "requires": ["DB", "CRON"], "crons": ["*/15 * * * *"], "intent": { "keywords": [ "cron", "uptime", "monitor", "scheduled", "health", "ping", "status" ], "examples": [ "uptime monitor", "scheduled health checks", "status page" ] }, "agentContext": { "summary": "An uptime monitor that checks URLs every 15 minutes, tracks latency and uptime percentage, with a live dashboard.", "full_text": "## Project Structure\n\n- `src/index.ts` - Hono API with routes, cron handler, admin page\n- `src/monitor.ts` - URL checking with groups, fetch with timeout, D1 storage\n- `src/admin.ts` - Inline HTML/CSS/JS dashboard (no external deps)\n- `schema.sql` - D1 schema (checks table with group_name)\n\n## Routes\n\n| Method | Path | Purpose |\n|--------|------|---------|\n| GET / | Live dashboard (HTML) |\n| GET /api/status | Per-group uptime stats (URLs hidden) |\n| GET /api/checks | Recent 100 checks (URLs hidden) |\n| POST /api/trigger | Manually trigger checks |\n| POST /__scheduled | Cron handler (called every 15 min) |\n| GET /health | Health check |\n\n## How It Works\n\nEvery 15 minutes the cron checks all monitored URLs grouped by name. URLs are never exposed publicly — only group names appear on the dashboard and in API responses.\n\nBy default it monitors `https://1.1.1.1` (Cloudflare DNS) in the \"Default\" group.\n\n## IMPORTANT: Cron handlers must await work\n\nDo NOT use `c.executionCtx.waitUntil()` in the `/__scheduled` handler — background tasks may be killed before they complete. Always `await` your work before returning the response:\n\n```typescript\n// WRONG — background work may be killed\napp.post('/__scheduled', async (c) => {\n c.executionCtx.waitUntil(doWork(c.env));\n return c.json({ ok: true });\n});\n\n// CORRECT — work completes before response\napp.post('/__scheduled', async (c) => {\n await doWork(c.env);\n return c.json({ ok: true });\n});\n```\n\n## Configuring Monitor Groups\n\nSet the `MONITOR_URLS` secret with named groups separated by semicolons:\n```\nProduction=https://api.example.com,https://app.example.com;Staging=https://staging.example.com/health\n```\n\nPlain URLs without a group name go into \"Default\":\n```\nhttps://example.com,https://api.example.com\n```\n\n## Dashboard\n\nThe dashboard auto-refreshes every 10 seconds and shows:\n- Status banner (all systems operational / issues detected)\n- Per-group cards with endpoint count, uptime %, avg latency\n- Recent checks table with group name and source (cron/manual)\n\nActual URLs are never shown — only group names are visible publicly.\n\n## Resources\n\n- [Hono Documentation](https://hono.dev)" }, "hooks": { "postDeploy": [ { "action": "clipboard", "text": "{{url}}", "message": "Deploy URL copied to clipboard" }, { "action": "shell", "command": "curl -s {{url}}/health | head -c 200", "message": "Testing worker health..." }, { "action": "box", "title": "Uptime monitor live: {{name}}", "lines": [ "{{url}}", "", "Dashboard: {{url}}/", "API: {{url}}/api/status", "", "Checks every 15 minutes automatically", "Configure: set MONITOR_URLS secret", " Format: Group=url1,url2;Other=url3" ] } ] } }