← Commit history

Merge PR #274: Spread the fleet's update cron over the half hour

Colby Knox ·c1c41c8e6a · ·parent 236c5b0
3 files changed +14−4
install.sh+12−2
@@ -129,7 +129,17 @@ fi # observable surface for a headless box is the status/log file the script writes # (~/.adom/last-update.status, ~/.adom/last-update.log), plus the CLI version it # reports to the registry on each update.-CRON_LINE_INTERVAL="*/30 * * * * $HOOK_CMD >/dev/null 2>&1"+# Each machine runs at its own two minutes of the hour, not */30: with every+# container in the fleet on */30, all of them checked at :00 and :30 at once+# (wiki.adom.inc 2026-10-20: about 2,400 version checks in the same 30 seconds,+# every half hour, against ~20 requests a second otherwise). The minute is a+# hash of this machine's name and HOME, so it is stable across reinstalls and+# spreads the fleet evenly over the half hour. ADOM_HOOK_CRON_MINUTE (0-29)+# overrides it.+CRON_MIN="${ADOM_HOOK_CRON_MINUTE:-$(( $(printf '%s' "$(uname -n 2>/dev/null)$HOME" | cksum | cut -d' ' -f1) % 30 ))}"+case "$CRON_MIN" in ''|*[!0-9]*) CRON_MIN=0 ;; esac+CRON_MIN=$(( CRON_MIN % 30 ))+CRON_LINE_INTERVAL="$CRON_MIN,$(( CRON_MIN + 30 )) * * * * $HOOK_CMD >/dev/null 2>&1" # The boot run waits ten minutes. On a fresh Hydrogen workspace the distro's first boot IS the # setup cascade (import, code-server start, the editor's extension host), and a full # `adom-wiki pkg update` in the same minute competed with it for a 4 vCPU box's CPU (winvm,@@ -151,7 +161,7 @@ if command -v crontab >/dev/null 2>&1; then   }   if { crontab -l 2>/dev/null | cron_filter; \        echo "$CRON_LINE_INTERVAL"; echo "$CRON_LINE_REBOOT"; } | crontab - 2>/dev/null; then-    echo "  registered cron for headless updates (*/30 + @reboot)"+    echo "  registered cron for headless updates (minutes $CRON_MIN and $(( CRON_MIN + 30 )) of each hour, + @reboot)"     # Another HOME's hook in the same user crontab is legal but almost always a     # mistake (a stray isolated-test install). Name it instead of leaving two     # updaters racing invisibly.
package.json+1−1
@@ -1,6 +1,6 @@ {   "slug": "hook",-  "version": "1.3.9",+  "version": "1.3.10",   "type": "app",   "org": "adom",   "bundled": true,
page.json+1−1
@@ -1,6 +1,6 @@ {   "slug": "hook",-  "version": "1.3.9",+  "version": "1.3.10",   "type": "app",   "org": "adom",   "bundled": true,