Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions .github/workflows/keep-warm.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
name: keep-warm

# Keeps the live demo awake from 08:00 to midnight IST: the free Render service
# sleeps after 15 idle minutes. It is left to sleep overnight on purpose, since
# only a boot resets the demo (docs/infra/DEPLOYMENT.md §0), so each morning
# starts fresh. An anonymous GET of the login page, never a sign-in: a sign-in
# writes an audit entry, and the reset only runs once nothing was audited for
# 10 minutes.
# Wakes the live demo on demand. The daily keep-awake ping runs on cron-job.org
# (docs/infra/DEPLOYMENT.md §0): GitHub's scheduler did not fire on time. An
# anonymous GET of the login page, never a sign-in: a sign-in writes an audit
# entry, and the demo only resets once nothing was audited for 10 minutes.

on:
schedule:
# Cron is UTC; IST is UTC+5:30. Every 5 minutes, because GitHub can start a
# scheduled run late and 10 minutes would leave no margin before the sleep.
- cron: '30-55/5 2 * * *' # 08:00-08:25 IST
- cron: '*/5 3-17 * * *' # 08:30-23:25 IST
- cron: '0-25/5 18 * * *' # 23:30-23:55 IST
workflow_dispatch:

permissions: {}
Expand Down
2 changes: 1 addition & 1 deletion docs/GAPS.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ platform. The *action* would not.
service, with Redis on Render Key Value and PostgreSQL on Neon. Any process
exiting restarts all three; there is no second instance and no failover.
- **It sleeps after 15 minutes without a request**, worker included, except
from 08:00 to midnight IST, when `keep-warm.yml` pings it. The first
from 08:00 to midnight IST, when a cron-job.org job pings it. The first
visit after a sleep waits for a cold boot (about 2.5 minutes, measured locally
under the same 0.1 CPU cap, not on the host).
- **The demo resets when idle.** A boot after 10 idle minutes (every wake from
Expand Down
23 changes: 13 additions & 10 deletions docs/infra/DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ memory figures below were measured locally under the same caps, not on the host.
- **It sleeps after 15 minutes without a request**, worker included. Locally,
capped at 0.1 CPU, a boot took about 2.5 minutes to serve the login page
(migrate, seed, then Next.js alone about 45 s).
- **It is kept awake from 08:00 to midnight IST.** `.github/workflows/keep-warm.yml`
GETs `/login` every 5 minutes in that window and lets it sleep overnight, so
each morning boots a fresh demo. Never a sign-in: that writes an audit entry,
which would stop the idle reset. About 480 of the 750 free hours a month, and
Neon's compute stays awake too, since the worker queries it on a timer.
GitHub can start a scheduled run late, so an occasional sleep in the window is
possible; a failed ping fails the run, and GitHub emails about it. Two
visitors on the same day share one demo.
- **It is kept awake from 08:00 to midnight IST** by a free cron-job.org job,
configured outside this repository: GET `https://<service>.onrender.com/login`,
every 5 minutes, hours 8-23, timezone Asia/Kolkata, failure email on. It
sleeps overnight, so each morning boots a fresh demo. Never a sign-in: that
writes an audit entry, which would stop the idle reset. About 480 of the 750
free hours a month, and Neon's compute stays awake too, since the worker
queries it every minute. The 08:00 ping is logged as failed (the boot outlasts
cron-job.org's request timeout) but still wakes it. Two visitors on the same
day share one demo. GitHub Actions was tried first and dropped: its scheduled
runs never fired on time. `.github/workflows/keep-warm.yml` remains as a
manual warm-up (`gh workflow run keep-warm.yml`).
- **512 MB and 0.1 CPU** for three Node processes. Measured locally under the
same caps: about 145 MB for the whole container, through a full incident
journey. Each heap is capped anyway (`API_HEAP_MB`, `WORKER_HEAP_MB`,
Expand Down Expand Up @@ -153,8 +156,8 @@ so they do not depend on a proxy in front of it.
1. **Access control.** One shared `demo` password. "Known users only" is true
only once Google sign-in with an exact-email allow-list is configured
(`AGENTS.md` §13a). **This is the real gate.**
2. **Uptime monitoring.** Only the keep-warm ping (§0), whose failed runs
email the workflow's author; nothing alerts on an incident being created.
2. **Uptime monitoring.** Only the cron-job.org ping (§0), whose failures
email its account owner; nothing alerts on an incident being created.
3. **Alerts on long open transactions.** The metric exists; nothing watches it.

The rest is in `docs/GAPS.md`.
Expand Down
8 changes: 4 additions & 4 deletions docs/infra/INFRA.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ than the code: the free tier returns 503 under load, and retired models answer

Five workflows in `.github/workflows/`. Only `changes.yml` runs on pushes and pull
requests to `main`; it calls `api.yml` and `web.yml`. `llm-live.yml` is manual;
`keep-warm.yml` runs on a schedule.
`keep-warm.yml` is manual too.

| Workflow | Role |
|---|---|
| `changes.yml` | The only entry point. Uses `dorny/paths-filter` to decide which service changed, then calls only the matching pipeline. The root `package.json`, lockfile and ESLint config fan out to both; `docker-compose.yml` counts for the api; a change only to workflows, top-level docs or the deploy files (`deploy/`, `render.yaml`, `scripts/`) runs neither. Also runs the **compose smoke and e2e** job whenever api or web changed: build the images, run `scripts/compose-smoke.sh`, then reset the stack (`down -v`, `up`) and run the Playwright journey (`npm run test:e2e -w @labops/web`); screenshots are uploaded only on failure, never traces, which hold cookies. |
| `api.yml` | build (`tsc` + `prisma validate`), lint and unit tests in parallel; then integration tests (real Postgres + Redis) and coverage; then the quality gate. Images are built by the compose smoke job whenever api or web changed |
| `web.yml` | build, lint and unit tests in parallel; then coverage; then the quality gate. Images are built by the compose smoke job whenever api or web changed |
| `llm-live.yml` | Manual only (`workflow_dispatch`): the one job that calls a real model; needs the `GEMINI_API_KEY` repository secret |
| `keep-warm.yml` | Scheduled every 5 minutes from 08:00 to midnight IST (and manual): an anonymous GET of the live `/login`, so the free service does not sleep in that window. No secrets, `permissions: {}` |
| `keep-warm.yml` | Manual only: an anonymous GET of the live `/login`, to wake the free service before showing it. The daily keep-awake runs on cron-job.org (`DEPLOYMENT.md` §0). No secrets, `permissions: {}` |

**Quality gate** (each pipeline, `if: always()` so it runs even after a failure):
1. Fails unless every upstream job succeeded.
Expand Down Expand Up @@ -255,8 +255,8 @@ https://labops.onrender.com. One container runs the API, worker and web app as
three processes, with Redis on Render Key Value and PostgreSQL on Neon. It
boots by resetting the demo database (`DEMO_RESET_ON_BOOT`), migrating, seeding
the `demo` operator and ingesting the demo scenario (`dist/seed-demo.js`), and
it sleeps after 15 minutes idle (kept awake 08:00 to midnight IST by
`keep-warm.yml`). `DEPLOYMENT.md` §0 has the costs and the steps.
it sleeps after 15 minutes idle (kept awake 08:00 to midnight IST by a
cron-job.org ping). `DEPLOYMENT.md` §0 has the costs and the steps.

**`APP_ENV=production` changes what the API accepts.** It refuses to boot if
`SESSION_COOKIE_SECURE` is not true (a Secure cookie over http is never sent,
Expand Down
Loading