/ scripts / overnight-enrich.sh
overnight-enrich.sh
 1  #!/usr/bin/env bash
 2  # Overnight Enrich loop - runs Enrich stage continuously using Playwright bundled browser
 3  # Started 2026-02-21 to process ~16,000 rescored English sites
 4  cd /home/jason/code/333Method
 5  
 6  LOG=logs/overnight-enrich.log
 7  echo "[$(date -Iseconds)] ==> Overnight Enrich loop started (PID $$)" >> "$LOG"
 8  
 9  BATCH=0
10  while true; do
11    BATCH=$((BATCH+1))
12    echo "[$(date -Iseconds)] Batch #$BATCH starting..." >> "$LOG"
13  
14    RESULT=$(CHROMIUM_PATH="" timeout 300 node scripts/run-enrich-batch.mjs 2>&1)
15  
16    STATUS=$?
17    echo "[$(date -Iseconds)] Batch #$BATCH exit=$STATUS result=$(echo "$RESULT" | grep 'DONE:\|NO_WORK\|Stage Complete' | head -3 | tr '\n' '|')" >> "$LOG"
18  
19    if echo "$RESULT" | grep -q "NO_WORK"; then
20      echo "[$(date -Iseconds)] No work - sleeping 120s" >> "$LOG"
21      sleep 120
22    elif [ $STATUS -ne 0 ]; then
23      echo "[$(date -Iseconds)] Error - sleeping 30s" >> "$LOG"
24      sleep 30
25    else
26      sleep 10
27    fi
28  done