@echo off
chcp 65001 >nul
setlocal
title Server repredict p6_latest
echo ============================================================
echo   Server: import_all_race_ai_compare_profiles.py
echo   profile: p6_latest
echo ============================================================
echo.

call "%~dp0_load-env.bat"
if errorlevel 1 goto end

echo server: %SERVER_SSH%
echo path:   %SERVER_PATH%
echo.
echo Runs in background on server. May take hours.
pause

ssh -o StrictHostKeyChecking=no %SERVER_SSH% "cd %SERVER_PATH% && mkdir -p logs && nohup python3 scripts/import_all_race_ai_compare_profiles.py --profile p6_latest >> logs/import_p6_latest_win.log 2>&1 & echo PID=$! && sleep 2 && tail -5 logs/import_p6_latest_win.log"
if errorlevel 1 (
  echo [NG] failed to start
  goto end
)

echo.
echo [OK] started in background.
echo  progress: ssh %SERVER_SSH% "tail -f %SERVER_PATH%/logs/import_p6_latest_win.log"
echo.

:end
pause
endlocal
