@echo off
setlocal
cd /d "%~dp0"

echo ==== 1. stop old GenServer ====
taskkill /F /IM GenServer.exe >nul 2>nul
timeout /t 1 /nobreak >nul

echo ==== 2. start GenServer (D-disk config) ====
start "GenServer" /min "%~dp0..\bin\GenServer.exe" "%~dp0genserver-config.json"
timeout /t 2 /nobreak >nul

echo ==== 3. health check ====
curl.exe -s http://localhost:8899/health
echo.

echo ==== 4. trigger /gen (KC0032-87) ====
curl.exe -s -X POST http://localhost:8899/gen -H "Content-Type: application/json" -d "{\"series\":\"KC\",\"params\":{\"type\":\"00\",\"bore\":32,\"stroke\":87,\"magnet\":\"\",\"mount\":\"\"},\"code\":\"KC0032-87\"}"
echo.

echo ==== 5. worker-config.txt (expect D-disk paths + nxBin) ====
type "worker-config.txt"

echo ==== 6. newest job files in D-disk jobs dir ====
dir /b /o-d "jobs\job_*.json" 2>nul

echo ==== done ====
endlocal
