@echo off
REM WakaTraffic - Fix Port Issue and Start Server
REM This script kills any process on port 5000 and starts the server

echo.
echo ===============================================
echo   WakaTraffic - Auto Fix and Start
echo ===============================================
echo.

cd /d "%~dp0"

echo Step 1: Killing any process using port 5000...
echo.

FOR /F "tokens=5" %%P IN ('netstat -ano ^| findstr :5000') DO (
    echo   Found process %%P on port 5000
    echo   Killing process...
    taskkill /PID %%P /F >nul 2>&1
)

echo   Port 5000 is now free!
echo.

echo Step 2: Waiting 2 seconds...
timeout /t 2 >nul

echo.
echo Step 3: Starting WakaTraffic server...
echo.
echo ===============================================
echo   Server starting on http://localhost:5000
echo   Keep this window open!
echo ===============================================
echo.

npm run dev

pause
