montana/Русский/Логистика/run_detail_loop.sh

40 lines
1.2 KiB
Bash

#!/bin/bash
# Loop wrapper: runs mt_detail_sweep.py --limit 20 repeatedly until no vessels remain
# Each iteration: fresh browser session, process 20 vessels, commit, exit cleanly
# This avoids browser exhaustion that occurs after ~25 vessels in a long session.
LOG="/tmp/mt_detail_live.txt"
LIMIT=20
DELAY=1.5
MAX_RUNS=500
DONE=0
RUN=0
cd "c:/project/Cursor/Логистика"
echo "[LOOP] Starting detail sweep loop at $(date)" | tee "$LOG"
while [ $RUN -lt $MAX_RUNS ] && [ $DONE -eq 0 ]; do
RUN=$((RUN + 1))
echo "" | tee -a "$LOG"
echo "[LOOP] === Run $RUN of max $MAX_RUNS at $(date) ===" | tee -a "$LOG"
python -u mt_detail_sweep.py --limit $LIMIT --delay $DELAY 2>&1 | tee -a "$LOG"
EXIT_CODE=$?
echo "[LOOP] Run $RUN exited with code $EXIT_CODE" | tee -a "$LOG"
# Check if nothing left to process
if grep -q "Nothing to do!" "$LOG" 2>/dev/null || grep -q "Vessels to process: 0" "$LOG" 2>/dev/null; then
echo "[LOOP] COMPLETE — no more vessels to process." | tee -a "$LOG"
DONE=1
break
fi
# Brief pause between runs to allow MT session to stabilize
echo "[LOOP] Waiting 5s before next run..." | tee -a "$LOG"
sleep 5
done
echo "[LOOP] Finished after $RUN runs."