This repository has no description
1#!/usr/bin/env bash
2# Wait for a running stage2-repos scrape, then run the next command.
3# Does NOT kill the stage2 process.
4#
5# Usage:
6# ./scraper/wait_then_run.sh stage4
7# ./scraper/wait_then_run.sh stage4 status
8#
9# Clears TANGLED_STAGE4_REPO_LIMIT so stage4 runs on ALL repos.
10
11set -euo pipefail
12
13ROOT="$(cd "$(dirname "$0")/.." && pwd)"
14cd "$ROOT"
15
16NEXT="${1:-stage4}"
17shift || true
18
19PID="$(pgrep -f "scrape.py stage2-repos" | head -1 || true)"
20
21if [[ -z "$PID" ]]; then
22 echo "No stage2-repos process found — running ${NEXT} now."
23else
24 echo "Waiting for stage2-repos (PID ${PID}) to finish ..."
25 echo " (stage2 still running — this script will NOT kill it)"
26 while kill -0 "$PID" 2>/dev/null; do
27 sleep 30
28 done
29 echo "Stage 2 finished."
30fi
31
32# shellcheck disable=SC1091
33source scraper/.venv/bin/activate
34
35unset TANGLED_STAGE4_REPO_LIMIT
36
37echo "Starting: python scraper/scrape.py ${NEXT} $*"
38python scraper/scrape.py "$NEXT" "$@"