#!/usr/bin/env bash
set -euo pipefail

ROOT="/root/.openclaw/workspace-flj_bot1/football-predictor-repro"
LOG_DIR="$ROOT/logs"
RUN_DIR="$ROOT/run"
LOG_FILE="$LOG_DIR/web_dashboard.log"
PID_FILE="$RUN_DIR/web_dashboard_supervisor.pid"

mkdir -p "$LOG_DIR" "$RUN_DIR"
echo $$ > "$PID_FILE"
cd "$ROOT"

while true; do
  echo "[$(date '+%F %T')] starting web_dashboard.py" >> "$LOG_FILE"
  python3 scripts/web_dashboard.py >> "$LOG_FILE" 2>&1 || true
  echo "[$(date '+%F %T')] web_dashboard.py exited, restarting in 3s" >> "$LOG_FILE"
  sleep 3
done
