@echo off
REM Kill all Node.js processes

echo.
echo ========================================
echo  Stopping WakaTraffic Server
echo ========================================
echo.

echo Killing all Node.js processes...
taskkill /IM node.exe /F /T >nul 2>&1

REM Verify
tasklist | findstr /I "node.exe" >nul
if %errorlevel% equ 0 (
    echo Still running... Trying harder...
    taskkill /IM node.exe /F /T
) else (
    echo [OK] Server stopped successfully
)

echo.
echo Clearing port 5000...
netstat -ano | findstr :5000 >nul
if %errorlevel% equ 0 (
    for /f "tokens=5" %%a in ('netstat -ano ^| findstr :5000') do (
        taskkill /PID %%a /F >nul 2>&1
    )
    echo [OK] Port 5000 cleared
)

echo.
echo [OK] All processes stopped
echo.
pause
