diff --git a/.github/workflows/keep-warm.yml b/.github/workflows/keep-warm.yml new file mode 100644 index 0000000..2c79855 --- /dev/null +++ b/.github/workflows/keep-warm.yml @@ -0,0 +1,33 @@ +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. + +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: {} + +concurrency: + group: keep-warm + cancel-in-progress: true + +jobs: + ping: + name: ping the live demo + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + # A cold boot takes about 2.5 minutes; the request itself is what wakes + # it, so a timeout here still leaves it booting. Only the status is kept. + - run: curl -fsS -o /dev/null --max-time 180 -w '%{http_code}\n' https://labops.onrender.com/login diff --git a/README.md b/README.md index f76ac2c..5b9aeb9 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,11 @@ worked. **Live demo: [labops.onrender.com](https://labops.onrender.com)** - Sign in as `demo`. The password is shared with the project submission. -- It runs on a free plan that sleeps after 15 minutes without a visit, so the - first visit can take a few minutes to wake up. After that, pages load in well - under a second. +- It runs on a free plan, kept awake from 08:00 to midnight India time and + asleep overnight. A visit while it sleeps can take a few minutes to wake it. + After that, pages load in well under a second. - Every wake-up starts a fresh demo. If an incident is already resolved when you - arrive, someone used it recently; it will be fresh after the next sleep. + arrive, someone used it earlier today; it will be fresh the next morning. > **Everything here is simulated.** The labs, their failures and the fixes are > generated by the project itself. It connects to no real cloud or lab diff --git a/docs/GAPS.md b/docs/GAPS.md index 6a5f6c5..79ff3ec 100644 --- a/docs/GAPS.md +++ b/docs/GAPS.md @@ -172,8 +172,9 @@ platform. The *action* would not. the API, the worker and the web app as three processes in one Render free 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. The first - visit after that waits for a cold boot (about 2.5 minutes, measured locally +- **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 + 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 sleep) drops and reseeds the demo database (`DEMO_RESET_ON_BOOT`), so diff --git a/docs/infra/DEPLOYMENT.md b/docs/infra/DEPLOYMENT.md index 6dfc517..9186e6b 100644 --- a/docs/infra/DEPLOYMENT.md +++ b/docs/infra/DEPLOYMENT.md @@ -41,7 +41,15 @@ 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). Warm it before showing it. + (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. - **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`, @@ -145,8 +153,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.** Nothing pings the site, and nothing alerts on an - incident being created. +2. **Uptime monitoring.** Only the keep-warm ping (§0), whose failed runs + email the workflow's author; 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`. diff --git a/docs/infra/INFRA.md b/docs/infra/INFRA.md index a6e2c19..e5ee675 100644 --- a/docs/infra/INFRA.md +++ b/docs/infra/INFRA.md @@ -183,8 +183,9 @@ than the code: the free tier returns 503 under load, and retired models answer ## 6. CI pipelines -Four 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. +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. | Workflow | Role | |---|---| @@ -192,6 +193,7 @@ requests to `main`; it calls `api.yml` and `web.yml`. `llm-live.yml` is manual. | `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: {}` | **Quality gate** (each pipeline, `if: always()` so it runs even after a failure): 1. Fails unless every upstream job succeeded. @@ -253,7 +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. `DEPLOYMENT.md` §0 has the costs and the steps. +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. **`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,