Skip to content

Commit 546beb7

Browse files
committed
Keep the API awake 08:00-23:59 IST on a schedule
Render's free service sleeps after ~15 idle minutes and takes up to a minute to wake. A scheduled workflow pings /api/healthz every 5 minutes during the day and lets it sleep overnight, which stays well inside the 750 free hours a month (~500 used). Also records Gate 1 in the plan and adds deploy troubleshooting notes for the REDIS_URL paste mistake and heartbeat-based reconnects.
1 parent 56d6302 commit 546beb7

3 files changed

Lines changed: 52 additions & 7 deletions

File tree

‎.github/workflows/keep-awake.yml‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Keep API awake
2+
3+
# Render's free service sleeps after ~15 idle minutes and takes ~30-60 s to wake. Pinging it
4+
# every 5 minutes keeps it warm from 08:00 to 23:59 IST; overnight it is left to sleep, which
5+
# keeps it well inside the 750 free instance-hours a month (~16 h a day ≈ 500 h).
6+
#
7+
# Cron runs in UTC; IST is UTC+5:30, so the window is 02:30-18:29 UTC. GitHub may start
8+
# scheduled runs a few minutes late, which the 5-minute spacing absorbs.
9+
on:
10+
schedule:
11+
- cron: '30-55/5 2 * * *' # 08:00-08:25 IST
12+
- cron: '*/5 3-17 * * *' # 08:30-23:25 IST
13+
- cron: '0-25/5 18 * * *' # 23:30-23:55 IST
14+
workflow_dispatch:
15+
16+
permissions: {}
17+
18+
concurrency:
19+
group: keep-awake
20+
cancel-in-progress: false
21+
22+
jobs:
23+
ping:
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 5
26+
steps:
27+
- name: Ping /api/healthz
28+
# The first ping of the morning wakes the service, so allow a slow answer and retries.
29+
run: >-
30+
curl --fail --silent --show-error --max-time 90
31+
--retry 3 --retry-delay 10 --retry-all-errors
32+
https://collabedit-api.onrender.com/api/healthz

‎docs/DEPLOY.md‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,18 @@ from the `main` branch.
5050
used for CORS and for the `Origin` check on the cookie endpoints; a mismatch makes the silent
5151
refresh fail with `untrusted_origin` after every reload.
5252

53-
### 6. Optional: keep the API awake
54-
The free service sleeps after ~15 idle minutes, and the first request then waits ~30–60 s. A free
55-
monitor such as UptimeRobot pinging `/api/healthz` every 10 minutes keeps it warm (750 free hours
56-
a month cover one service running all month). Open the app a minute before a demo either way.
53+
### 6. Keep the API awake during the day
54+
The free service sleeps after ~15 idle minutes, and the first request then waits ~30–60 s. The
55+
`Keep API awake` workflow (`.github/workflows/keep-awake.yml`) pings `/api/healthz` every
56+
5 minutes from 08:00 to 23:59 IST and lets the service sleep overnight (~500 of the 750 free
57+
hours a month). Notes:
58+
59+
- Scheduled workflows run only from the default branch (`main`), and GitHub pauses them after
60+
60 days without commits; re-enable it from the Actions tab if that happens.
61+
- GitHub can start scheduled runs late or skip one under load, so the service may still
62+
occasionally fall asleep. For a hard guarantee before an interview or demo, run the workflow by
63+
hand (**Actions → Keep API awake → Run workflow**) or open the app a minute early.
64+
- To change the hours, edit the three `cron` lines; they are in UTC (IST − 5:30).
5765

5866
## Smoke test after deploying
5967

@@ -72,4 +80,5 @@ a month cover one service running all month). Open the app a minute before a dem
7280
| Editor stuck on "Syncing…" | `VITE_WS_URL` missing or wrong (must be `wss://…onrender.com`), or the API is waking |
7381
| `readyz` shows database `error` | Pooled Neon URL used, or wrong password |
7482
| Rate-limit 503 on login | Redis unreachable; login fails closed by design |
83+
| Editors reconnect ~35 s after a deploy, not instantly | Expected: Render's edge does not forward the server's WebSocket close frame, so clients notice through the heartbeat (ADR 0012) |
7584
| Startup fails: `REDIS_URL must start with redis://` | Pasted the whole `redis-cli -u …` command, or added quotes; paste only the `redis://…` URL |

‎docs/PLAN.md‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ of week 6 (Gate 1) and the full v2 at the end of week 14 (Gate 2), on $0/month h
4545
a real browser with two accounts, including killing the API mid-edit
4646
- Found upstream: pycrdt/yrs 0.27 drops some out-of-order updates (Yjs does not); see ADR 0012
4747
- [ ] **3 · Storage, versions, search** (week 5)
48-
- [ ] **4 · Sharing and roles** (week 6) → **Gate 1: MVP live on the web**
48+
- [x] **4 · Sharing and roles** (week 6) → **Gate 1: MVP live on the web** ✅ 2026-10-01
4949
- [x] Members: list, invite by email with a role, change role, remove, leave, transfer ownership
5050
- [x] Share links: role, expiry, turn off; token shown once and stored hashed; accept never
5151
lowers access; token sent in the body so it stays out of logs
@@ -55,8 +55,12 @@ of week 6 (Gate 1) and the full v2 at the end of week 14 (Gate 2), on $0/month h
5555
asyncpg; migrations at container start; production refuses a dev secret or insecure
5656
cookies; config errors never echo secrets
5757
- [x] 121 API tests, 64 web tests; production image rehearsed locally against a fresh database
58-
- [ ] Accounts on Neon, Redis Cloud, Render and Vercel, then deploy (see docs/DEPLOY.md)
59-
- [ ] Merge `v2` into `main` (the deploy branch) and run the smoke test
58+
- [x] Deployed: web <https://collaborative-editor-flax.vercel.app>, API
59+
<https://collabedit-api.onrender.com>, Neon Postgres 18 and Redis Cloud (all Singapore)
60+
- [x] Production smoke test, 31/31: frontend, auth and cookie rotation, documents, sharing,
61+
live editing between two accounts (~110 ms), presence, persistence, revocation
62+
- Found in production: Render's edge drops WebSocket close frames; client heartbeat added
63+
- [x] Scheduled ping keeps the free API awake 08:00–23:59 IST and lets it sleep overnight
6064
- [ ] **5 · Multi-instance Redis** (week 7)
6165
- [ ] **6 · Comments** (week 8)
6266
- [ ] **7 · Branches and merge requests** (weeks 9–10)

0 commit comments

Comments
 (0)