← back to Re Flyer Aggregator
scripts/property-flyers-cron.sh
20 lines
#!/bin/bash
# TK-10708 Daily property-flyer refresh: crawl CA broker listing pages for property one-sheets,
# then push the fresh gallery live to flyers.crcp.agentabrams.com. $0 (local crawl + rsync).
# Driven by launchd com.steve.property-flyers (daily). PATH baked (launchd has none).
export PATH=/opt/homebrew/bin:/opt/homebrew/opt/postgresql@14/bin:/usr/bin:/bin:/usr/sbin:/sbin
cd "$HOME/Projects/re-flyer-aggregator" || exit 1
LOG=data/property-flyers-cron.log
echo "=== property-flyer refresh $(date) ===" >> "$LOG"
node scripts/property-flyers.mjs --n 150 --pages 6 --delay 700 >> "$LOG" 2>&1
# TK-11856 rc-propagation (exit-code ONLY, no behavior change): the rsync still runs after a failed
# crawl exactly as before; we capture the crawl rc (previously swallowed) + the rsync rc and exit with
# the first nonzero instead of whatever the trailing && list returned. Undo: git revert.
CRAWL_RC=$?
rsync -az -e ssh public/flyers-found/ root@45.61.58.125:/var/www/flyers.crcp.agentabrams.com/flyers-found/ >> "$LOG" 2>&1
RSYNC_RC=$?
[ "$RSYNC_RC" -eq 0 ] && echo "deployed $(node -e "console.log(require('./public/flyers-found/property-flyers.json').length)") flyers $(date)" >> "$LOG"
echo "=== exit crawl=$CRAWL_RC rsync=$RSYNC_RC ===" >> "$LOG"
if [ "$CRAWL_RC" -ne 0 ]; then exit "$CRAWL_RC"; fi
exit "$RSYNC_RC"