Status application and health checks
The status application is an independent Next.js service for status.cap.so. It checks the main Cap service paths on a schedule, keeps a short health history, and presents a public view of current status, observed uptime, and incidents. It is separate from the main web app and does not run recording or upload tests.
System purpose
The application turns small, public service checks into a clear status view for Cap users and operators. A scheduled collector measures service reachability and health. The public page reads the saved result instead of probing services during a visitor request.
The status site covers these service areas:
| Service area | What the check represents |
|---|---|
| Website | Public site and download reachability |
| API and authentication | Authentication API availability and provider data |
| Video sharing | Access to a public shared recording |
| Storage and delivery | Access to a public storage or CDN canary |
| Media processing | Media server health |
| Cloud rendering | Render coordinator health and available capacity |
For the wider monitoring model, see Service status monitoring.
Monitoring lifecycle
The monitoring lifecycle separates collection from display. The scheduler checks all configured services, the state model confirms meaningful changes, and the public API exposes only a safe snapshot.
flowchart LR
Scheduler[Five-minute scheduler] --> Collector[Authenticated check endpoint]
Collector --> Probes[Service probes]
Probes --> State[State and incident model]
State --> Redis[Dedicated Redis state]
Redis --> API[Public status API]
API --> Page[Status page]
Service probes
The probe layer uses direct HTTPS canaries and treats a response as healthy only when it matches the service contract. It uses small requests with a time limit, avoids redirects, and retries an unhealthy result once so a short network fault does not immediately become a confirmed incident.
Response time above three seconds is degraded. A failed request is an outage result. Health endpoints also need valid service-specific data, so an HTTP success alone cannot hide a broken media or render service. apps/…/probe.ts• L7-79 and apps/…/services.ts• L3-67
References: apps/…/probe.ts• L7-79 apps/…/services.ts• L3-67
State model
The state model records the latest result for each service and daily observations for the last 90 UTC days. It keeps gaps as unknown data, so uptime describes observed checks rather than unmonitored time. Services without valid configuration also remain unknown. The model uses the Health, Day, Incident, ServiceState, and MonitorState types to keep private monitor state distinct from the public snapshot types. apps/…/types.ts• L1-35
The model uses consecutive samples to reduce noise. One unhealthy sample can show a degraded condition. Two unhealthy samples open an incident. Two successful samples confirm recovery. A monitoring gap resets the counters and does not resolve an open incident. apps/…/state.ts• L11-18 and apps/…/state.ts• L74-170
References: apps/…/state.ts• L11-18 apps/…/state.ts• L41-72 apps/…/state.ts• L74-170 apps/…/types.ts• L1-35
Public snapshot
The public snapshot is a display-safe view of the monitor state. It contains service names, descriptions, status, response time, observed daily history, and recent incidents. It does not expose monitor URLs, health payloads, or storage credentials. apps/…/types.ts• L37-61
The snapshot marks an observation as unknown when it is missing or older than 15 minutes. Resolved incidents and daily history are limited to the public 90-day view. apps/…/state.ts• L173-209
References: apps/…/state.ts• L173-209 apps/…/types.ts• L37-61
Public status interface
The public interface has two parts: a JSON API for machines and a page for people. Both use the same saved snapshot, which keeps the displayed result consistent with the API result.
Status API
/api/status returns the current public snapshot without starting new checks. The response can be shared through a short CDN cache. Query parameters are rejected so callers cannot create unlimited cache variants. If storage cannot be read, the endpoint returns a non-success response with unknown service data instead of serving stale success as if it were current. apps/…/route.ts• L4-26
References: apps/…/route.ts• L4-26
Status page
The page gives users a plain-language summary, one row for each service, daily history for 90 days, and incident history. It refreshes about once per minute while visible and treats an unavailable API or old snapshot as unknown. Visitors can expand a service to see its latest response and check time, then inspect individual days with pointer or keyboard input. The layout adapts to small screens and keeps visible focus states for keyboard use. It also reduces decorative motion when the visitor requests reduced motion. apps/…/status-page.tsx• L40-125, apps/…/service-row.tsx• L35-169, and apps/…/globals.css• L43-48
The overall message follows the most serious visible service state. An outage takes priority over degraded status, which takes priority over unknown status. This prevents a healthy service from hiding a more serious condition elsewhere in the system. apps/…/status-page.tsx• L30-38
References: apps/…/status-page.tsx• L30-38 apps/…/status-page.tsx• L40-125 apps/…/service-row.tsx• L35-169 apps/…/globals.css• L43-48 apps/…/globals.css• L716-965
Scheduled checks
The scheduled endpoint is the only component that probes production services. Vercel calls /api/cron/check every five minutes in production. The endpoint requires the configured Bearer secret and skips preview deployments.
When the endpoint runs, it takes a short Redis lease, checks the service set in parallel, applies the results to the state model, and saves the state only if it still owns the lease. It skips duplicate work within the same five-minute interval. This protects history from overlapping or repeated scheduler calls. apps/…/route.ts• L14-77
sequenceDiagram
participant V as Vercel cron
participant C as Check endpoint
participant S as Service canaries
participant R as Dedicated Redis
V->>C: Authenticated request
C->>R: Acquire short lease
C->>S: Probe configured services
S-->>C: Health and latency results
C->>C: Apply state and incident rules
C->>R: Commit state if lease is valid
C-->>V: Check result or skip
The scheduler uses a dedicated Redis database for monitor state. The deployment must provide the Redis connection and a strong cron secret. Each service can use an environment URL or its safe default, but missing or invalid service configuration never becomes a healthy result. apps/…/store.ts• L5-25 and apps/…/services.ts• L53-67
References: apps/…/route.ts• L14-77 apps/…/store.ts• L5-25 apps/…/services.ts• L53-67
Deployment boundary
The status app runs as a separate Vercel project with apps/status as its root. Its build and cron settings live with the app. The project uses a dedicated Redis store and should not receive the main site’s environment values. apps/…/README.md• L5-14 and apps/…/vercel.json• L2-5
Production checks run only on a deployment that supports five-minute cron jobs. Operators also need an external dead-man monitor for an old checkedAt value, a failed API response, or an unreachable status site. This catches a failed scheduler, storage outage, or status deployment outage that the page cannot report by itself. apps/…/README.md• L7-12
The app sets basic response protections at the Next.js boundary. Public API traffic should also have a project-level rate limit because the API is intentionally public. apps/…/next.config.ts• L3-17 and apps/…/README.md• L11-12
References: apps/…/README.md• L5-14 apps/…/vercel.json• L2-5 apps/…/next.config.ts• L3-17
Verification coverage
The status app has focused tests for the three contracts that matter most: probe meaning, state transitions, and route coordination. The test suite checks that transport failures and invalid health data are not reported as healthy, that incidents need confirmation, and that public routes fail closed when storage or authorization is unavailable.
Route tests also cover the deployment schedule, preview protection, duplicate scheduler calls, lease ownership, cache behavior, and the boundary between private monitor inputs and the public snapshot. The app workflow runs these tests and a production build when status-app changes reach pull requests or main. apps/…/probe.test.ts• L10-85, apps/…/state.test.ts• L17-137, apps/…/routes.test.ts• L105-224, and .github/…/status.yml• L19-31
References: apps/…/probe.test.ts• L10-85 apps/…/state.test.ts• L17-137 apps/…/routes.test.ts• L105-224 .github/…/status.yml• L19-31
Change checklist
When these files or sections are changed, remember to consider these:
- When a service definition changes, align its URL setting, request type, health validation, public description, and route-test fixture.
- When the state or public snapshot shape changes, review both Redis data compatibility and the page’s handling of unknown or stale data.
- When the check interval or cron schedule changes, keep the duplicate-sample guard, stale threshold, deployment schedule, and UI freshness text consistent.
- When the public API cache or error behavior changes, review the page polling behavior and the external dead-man monitor contract.
- When a status state or interaction changes, keep the page behavior, state-specific visual treatment, keyboard focus, and reduced-motion behavior aligned.
- When deployment settings change, keep production-only collection, the cron secret, the dedicated Redis store, and the five-minute scheduler requirement aligned.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Redis cannot be read | The API returns 503 with unknown data; the page cannot claim current health | External dead-man monitoring and explicit no-success fallback |
| A service URL is missing or invalid | The service stays unknown and creates no false outage | HTTPS-only URL validation and unconfigured state handling |
| One unhealthy probe occurs | The service may look degraded but no incident opens | Immediate retry and two consecutive unhealthy samples |
| The scheduler runs twice or overlaps | History could be double-counted without coordination | Five-minute interval check and expiring Redis lease |
| A monitoring gap occurs | Old data is no longer treated as current; an incident remains unresolved | Stale threshold and counter reset without automatic recovery |
| A preview deployment receives a cron call | Preview could probe production services | Production-only collection guard |
Key files
| File | Why to read it |
|---|---|
| apps/…/services.ts | Defines the service areas and their probe contracts |
| apps/…/probe.ts | Explains how reachability, latency, retries, and health payloads become results |
| apps/…/state.ts | Defines freshness, history, uptime, incident, and public snapshot behavior |
| apps/…/types.ts | Defines the private state and public snapshot contracts |
| apps/…/route.ts | Shows the scheduled collection boundary and lease-protected save flow |
| apps/…/route.ts | Defines the public machine-readable interface and failure response |
| apps/…/status-page.tsx | Shows how the public page turns snapshots into user-facing status |
| apps/…/globals.css | Defines the responsive, accessible visual treatment for status states and history |
| apps/…/vercel.json | Defines the production build and scheduled check configuration |
| apps/…/routes.test.ts | Covers the scheduler, storage, API, and deployment coordination contract |