johnandersen777.bsky.social/socialweb-computer-watch
The socialweb.computer market's live topology from Jetstreams and relays, deduplicated; capture and replay
0
0
#!/bin/sh
# Starts capture.mjs in the background for a CI workflow and returns: the default sources, every frame kept
# (duplicates too: the page shows the dedup), one NDJSON line each, appended as it arrives, so a kill leaves a
# loadable file; Jetstreams start 15 min back (SWC_WATCH_REWIND), so what the run did before this step is in it. Linux needs only curl, tar, xz, git and libatomic1: Node v26.13.0 (sha256 checked) when there is no node >= 22.
# scripts/ci-capture.sh <out.ndjson> [seconds, default 7200]
# Its log: <out.ndjson>.log; its pid: <out.ndjson>.pid (kill it to stop early).
set -eu
out=$1
seconds=${2:-7200}
dir=$(cd "$(dirname "$0")/.." && pwd)
node=node
if ! node -e 'process.exit(+process.versions.node.split(".")[0] >= 22 ? 0 : 1)' 2>/dev/null; then
case $(uname -m) in
x86_64) arch=x64 sum=d28a96af6c38596f6d9d97c0ee531c13d238d757742387d1928de822d959e997 ;;
aarch64) arch=arm64 sum=406fe3fbde1c054adff8b297c16fdb5af6659db327c1ac8acd46b56ef1af9a92 ;;
*) echo "no node for $(uname -m)" >&2; exit 1 ;;
esac
n=node-v26.13.0-linux-$arch
if [ ! -x "$dir/.node/$n/bin/node" ]; then
mkdir -p "$dir/.node"
curl -fsSL --max-time 120 -o "$dir/.node/$n.tar.xz" "https://nodejs.org/dist/v26.13.0/$n.tar.xz"
echo "$sum $dir/.node/$n.tar.xz" | sha256sum -c - >/dev/null
tar -C "$dir/.node" -xJf "$dir/.node/$n.tar.xz"
fi
node=$dir/.node/$n/bin/node
"$node" --version >/dev/null || { echo "$node does not run (Debian/Ubuntu: apt-get install libatomic1, which build-essential brings)" >&2; exit 1; }
PATH=$dir/.node/$n/bin:$PATH
fi
[ -d "$dir/node_modules/@publicdomainrelay/atlibs" ] || (cd "$dir" && npm ci --omit=dev --no-audit --no-fund >/dev/null)
mkdir -p "$(dirname "$out")"
nohup setsid "$node" "$dir/capture.mjs" --all --rewind-minutes "${SWC_WATCH_REWIND:-15}" --out "$out" --seconds "$seconds" >"$out.log" 2>&1 </dev/null &
echo $! >"$out.pid"
echo "capturing to $out (pid $(cat "$out.pid"), log $out.log, for ${seconds}s)"