Repository navigation
Conversation
The analyser asked for work every 30 seconds even when there was none, so the website never went quiet long enough for Railway to sleep it. Double the wait between empty polls from IDLE_SLEEP_MIN (60s) up to IDLE_SLEEP_MAX (1800s), resetting as soon as an app is assigned, and retry transient curl failures for up to a minute so requests survive the server waking up. The analyser's last check-in was only held in memory, so a woken process reported it offline until the next ping. Store it in an analyser_heartbeat row and read it back once per process. Claude-Session: https://claude.ai/code/session_01Fi3H98SycMK13rrr8ySSU1
|
CI is red at the The failure is not from this PR: it doesn't touch dependencies. The advisories ( Generated by Claude Code |
|
Closing in favour of #39. That PR drops the polling entirely: the analyser waits for an ntfy wake-up or the next due time, and it keeps the stored heartbeat and curl retries from this PR. Generated by Claude Code |
What
When there was no work, the analyser called
/pingand/queueabout every 30 seconds. Railway only sleeps a service after 5–10 minutes without outbound traffic, and responses to inbound requests count as outbound traffic, so the website never slept.analyser/processQueue.sh: after an empty or failed/queue, waitIDLE_SLEEP_MIN(60 s), doubling each time up toIDLE_SLEEP_MAX(1800 s). The wait goes back to the minimum once an app is assigned. Every curl call now retries transient failures (connection refused, 5xx including Railway's cold-start 502) for up to 60 s. Retrying an upload whose first attempt did land just gets a 409 for the spent claim.lastPing), so a woken process showed "Analyser offline" until the next ping. It is now also written to a one-rowanalyser_heartbeattable (migration015) and read back once per process. A failed read is retried after a minute, and a failed write is logged without failing/ping.analyser/.env.exampleandraspberry-pi-analyser.md.Trade-off: an app requested while the queue is empty can wait up to
IDLE_SLEEP_MAX(30 min by default) before the analyser picks it up. The Pi's checkout needs updating for the script change to take effect.Testing
npm test: 165/165 pass, including the newtest/analyserHeartbeat.test.js(the stored heartbeat is read once per process and/pingwrites it).015(applied twice) and the heartbeat upsert/read against a local Postgres 16. TheCHECK (id)constraint rejects a second row.idle_backoffwith small limits: 1, 2, 4, 5, 5 s.CI will fail at the
npm auditstep until #37 merges; the advisories are unrelated to this change.https://claude.ai/code/session_01Fi3H98SycMK13rrr8ySSU1
Generated by Claude Code