igneum/tools/observer/run.sh
igneum-labs adc52b9c83 Observer: decoupled ingest, lag metric, per-minute by header time, feed self-check, restart loop
After the 4 Oct 2026 stall (no block stored from 11:57 to 13:15 UTC, then 7,022
blocks in two minutes). Notifications only enqueue; a drain loop handles them
in bounded batches. Block flush, colour marking and certificate work each run
on their own timer and never wait on one another. Mergesets come from the
notification's verbose data (bounded cache); getBlock only on a miss, four at
a time. live_state gains observer_lag_s and queue_depth; the API serves them;
the page shows "observer N s behind" past 30 s instead of waiting for the
first block. blocks_per_minute and blocks_60s are bucketed by the block's own
timestamp and reseeded from the table on start, so a catch-up fills past
minutes instead of painting a spike. If no blockAdded arrives for 60 s while
the node's block_count advances, the observer resubscribes; after two failed
attempts it exits 2 and tools/observer/run.sh restarts it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-04 13:26:46 +00:00

20 lines
932 B
Bash
Executable file

#!/bin/sh
# Restart loop for the devnet observer. An exit (the observer exits 2 when it loses the block feed and two
# resubscribes do not bring it back) is a restart three seconds later. Start it detached from the repo root:
#
# nohup tools/observer/run.sh >/dev/null 2>&1 &
#
# Environment: IGNEUM_RPC (default ws://127.0.0.1:28640, the Mac's non-mining peer with a JSON listener),
# OBSERVER_LOG (default /tmp/igneum-devnet/observer-mjs-v4.out, appended). Everything else as observer.mjs.
cd "$(dirname "$0")/../.." || exit 1
export IGNEUM_RPC="${IGNEUM_RPC:-ws://127.0.0.1:28640}"
LOG="${OBSERVER_LOG:-/tmp/igneum-devnet/observer-mjs-v4.out}"
mkdir -p "$(dirname "$LOG")"
exec >>"$LOG" 2>&1
echo "$(date -u +%FT%TZ) run.sh: observer loop started, rpc $IGNEUM_RPC, pid $$"
while :; do
node tools/observer/observer.mjs
code=$?
echo "$(date -u +%FT%TZ) run.sh: observer exited with $code, restarting in 3 s"
sleep 3
done