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

35 lines
1020 B
Bash
Raw Permalink Normal View History

#!/bin/bash
# Auto-restart wrapper for mt_detail_sweep.py
# Restarts on crash, stops when "DONE" is seen or nothing left to process
LOG="/tmp/mt_detail_live.txt"
ATTEMPTS=0
MAX_ATTEMPTS=20
cd "c:/project/Cursor/Логистика"
while [ $ATTEMPTS -lt $MAX_ATTEMPTS ]; do
ATTEMPTS=$((ATTEMPTS + 1))
echo "[WRAPPER] Starting attempt $ATTEMPTS at $(date)" | tee -a "$LOG"
python -u mt_detail_sweep.py 2>&1 | tee -a "$LOG"
EXIT_CODE=$?
echo "[WRAPPER] Script exited with code $EXIT_CODE at $(date)" | tee -a "$LOG"
# Check if done (no more vessels to process)
if grep -q "Nothing to do!" "$LOG" 2>/dev/null; then
echo "[WRAPPER] COMPLETE — nothing left to process." | tee -a "$LOG"
break
fi
if grep -q "DONE in" "$LOG" 2>/dev/null; then
echo "[WRAPPER] COMPLETE — DONE message found." | tee -a "$LOG"
break
fi
echo "[WRAPPER] Restarting in 10s..." | tee -a "$LOG"
sleep 10
done
echo "[WRAPPER] Finished after $ATTEMPTS attempts."