igneum/tools/workers/publish-workers.sh
igneum-labs 71881c1926 Worker dashboard: collector on igneum-build-1, Mac pusher, workers.html next to the fleet page (the project lead, 6 October 2026)
tools/workers/collect.mjs runs every 30 s on the box (infra/build-server/workers/igneum-workers.{service,timer},
install.sh) and writes /srv/workers/workers.json from the machine itself: /proc/stat deltas per core, meminfo, df on
/srv, net bytes, hwmon temperatures, the flock state of /srv/builds/_locks, cargo processes with worktree, target and
start time, flock waiters, /srv/builds/_log/builds.jsonl (the format agreed with the build-server agent), sccache
--show-stats, headline.json. tools/workers/push.mjs (launchd every 60 s) adds the Mac's with-lock slots and waiters
and the two PCs' relay job states from the intake, drops them on the box so its file is whole, merges the box's file
and writes the fleet folder's workers.json; it deploys only when the live copy is over 6 min old, otherwise the
fleet orchestrator's 5-minute deploy carries it. The page (tools/workers/page/workers.html, shape.js) tries
https://build.igneum.network/workers.json first and falls back to the folder copy; core strip, arcs, now building,
queue, recently done with closing lines, headline timings, analytics; UK time with UTC tooltips; phone width.
node --test tools/workers/test: 13 tests over /proc/stat, lock dir, JSONL and sccache fixtures and the page shaping.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-06 17:59:07 +00:00

35 lines
2.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# Put the worker dashboard page next to the fleet page and deploy the folder through publish-fleet.sh's mechanism.
# tools/workers/publish-workers.sh copy workers.html, shape.js, workers.demo.json; one push.mjs pass; deploy
# tools/workers/publish-workers.sh --no-deploy copy only (the fleet orchestrator's next deploy carries it)
# The folder is $DLSITE/<fleet-path>/ (dlsite-dir and fleet-path in ~/.config/igneum). The fleet index.html gets the
# Workers nav link if it does not carry one yet (the fleet page has no repo source; this is the only edit made to it).
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"; ROOT="$(cd "$HERE/../.." && pwd)"
DLSITE="$(cat "$HOME/.config/igneum/dlsite-dir")"; P="$(cat "$HOME/.config/igneum/fleet-path")"
DIR="$DLSITE/$P"; [ -d "$DIR" ] || { echo "no $DIR" >&2; exit 1; }
cp "$HERE/page/workers.html" "$DIR/workers.html"
cp "$HERE/shape.js" "$DIR/shape.js"
cp "$HERE/fixtures/workers.demo.json" "$DIR/workers.demo.json"
if ! grep -q 'workers.html' "$DIR/index.html"; then
python3 - "$DIR/index.html" <<'PY'
import sys, re
p = sys.argv[1]; s = open(p).read()
css = " nav { display: flex; gap: 2px; border: 1px solid var(--line); }\n nav a { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); text-decoration: none; padding: 7px 12px; }\n nav a.on { color: var(--ink); background: var(--panel-2); }\n nav a:hover { color: var(--ember-2); }\n"
s = s.replace(" .live {", css + " .live {", 1)
s = s.replace(' <div class="live"><b></b><span id="stamp">', ' <nav aria-label="Pages"><a href="./" class="on" aria-current="page">Fleet</a><a href="workers.html">Workers</a></nav>\n <div class="live"><b></b><span id="stamp">', 1)
open(p, 'w').write(s)
print("nav link added to the fleet index.html")
PY
fi
node "$HERE/push.mjs" --no-deploy
if [ "${1:-}" != --no-deploy ]; then
tmp="$(mktemp)"; cp "$DIR/fleet.json" "$tmp"
"$ROOT/tools/fleet/publish-fleet.sh" "$tmp" >/dev/null || "/Users/joshm/Projects/igneum/tools/fleet/publish-fleet.sh" "$tmp"
rm -f "$tmp"
for i in $(seq 1 12); do
if curl -fsS --max-time 10 "https://dl.igneum.network/$P/workers.html?t=$(date +%s)" | grep -c "Igneum Workers" >/dev/null; then echo "live: https://dl.igneum.network/$P/workers.html"; exit 0; fi
sleep 5
done
echo "deployed but the edge does not serve workers.html yet" >&2; exit 2
fi