-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·32 lines (30 loc) · 1.45 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·32 lines (30 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
# Supervisor: keeps the capture running for as long as it takes, unattended.
# The capture already handles throttling internally (adaptive rate + escalating cooldowns)
# and checkpoints after every pick. This wrapper just relaunches it if the *process* dies
# (crash / OOM / kill), resuming via SKIP_EXISTING, and stops once a full pass adds nothing new.
#
# ./run.sh [site] # e.g. ./run.sh stripe (default: stripe)
#
# Survives crashes and sleep. To also survive reboots, run it under launchd (ask Claude for a plist).
set -u
cd "$(dirname "$0")"
SITE="${1:-${SITE:-stripe}}"
DIR="sites/$SITE/shots"
LOG="capture-$SITE.log"
count() { ls "$DIR"/*.webp 2>/dev/null | grep -v '\.tmp-' | wc -l | tr -d ' '; }
echo "[supervisor] $(date '+%F %T') starting for $SITE — logging to $LOG"
while true; do
before=$(count)
echo "[supervisor] $(date '+%F %T') launching capture ($before shots on disk)" | tee -a "$LOG"
SITE="$SITE" GOVERN=1 SKIP_EXISTING=1 node capture.mjs >> "$LOG" 2>&1
code=$?
after=$(count)
echo "[supervisor] $(date '+%F %T') capture exited code=$code ($before -> $after shots)" | tee -a "$LOG"
if [ "$code" = "0" ] && [ "$after" = "$before" ]; then
echo "[supervisor] $(date '+%F %T') clean pass with no new shots — all reachable picks captured. Done." | tee -a "$LOG"
break
fi
echo "[supervisor] $(date '+%F %T') exited (crash or progress) — relaunching in 30s (Ctrl-C to stop)" | tee -a "$LOG"
sleep 30
done