← back to Dw Scrape Scheduler

scripts/dispatch-run.sh

23 lines

#!/bin/bash
# Daily launchd entrypoint for the staggered monthly fleet scrape.
# Runs the dispatcher, which itself selects ONLY the vendors whose assigned
# day-of-month == today (concurrency cap 2). Most days that's 0-2 vendors, so
# the fleet is spread across the month and never thundered all at once.
# Local-models-only: feed adapters need no model; Gemini enrich is never invoked.
set -uo pipefail
export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

PROJ="/Users/macstudio3/Projects/dw-scrape-scheduler"
LOG="/tmp/dw-scrape-dispatcher.log"
cd "$PROJ" || { echo "$(date '+%F %T') FATAL cd failed" >>"$LOG"; exit 1; }

echo "===== $(date '+%F %T') dispatcher START (day $(date '+%d')) =====" >>"$LOG"
node dispatcher.js >>"$LOG" 2>&1
rc=$?
echo "===== $(date '+%F %T') dispatcher END rc=$rc =====" >>"$LOG"

# Best-effort CNCP heartbeat (never blocks the run)
curl -s -X POST http://127.0.0.1:3333/api/wins -H 'Content-Type: application/json' \
  -d "{\"project\":\"dw-scrape-scheduler\",\"title\":\"daily fleet-scrape tick\",\"summary\":\"staggered monthly vendor scrape, day $(date '+%d'), rc=$rc\"}" >/dev/null 2>&1 || true
exit $rc