@echo off REM ================================================================ REM Verwaltet die lokale Web-Testinstanz (FastAPI/uvicorn, M1) REM REM run_web.bat start - startet den Server im Hintergrund REM run_web.bat stop - beendet den Server (inkl. Reload-Kindprozesse) REM run_web.bat status - zeigt ob und unter welcher PID er laeuft REM run_web.bat - startet im Vordergrund (Strg+C zum Beenden) REM REM http://localhost:8000 Testoberflaeche REM http://localhost:8000/docs interaktive API-Doku (Swagger) REM REM Die Prozess-/Portlogik liegt in run_web_helper.ps1 (cmd-Escaping REM von mehrzeiligen PowerShell-Kommandos ist zu fehleranfaellig). REM ================================================================ call "%~dp0setenv.bat" > nul set WEB_PORT=8000 set HELFER=powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0run_web_helper.ps1" if /I "%~1"=="start" goto :start if /I "%~1"=="stop" goto :stop if /I "%~1"=="status" goto :status if "%~1"=="" goto :vordergrund echo Unbekannter Parameter "%~1" - erlaubt: start ^| stop ^| status exit /b 1 REM ---------------------------------------------------------------- :vordergrund call :venv_pruefen || exit /b 1 echo Starte Web-Testinstanz im Vordergrund (Strg+C zum Beenden) ... python -m uvicorn main:app --reload --app-dir "%PLATZ%\web" --port %WEB_PORT% exit /b %errorlevel% REM ---------------------------------------------------------------- :start call :venv_pruefen || exit /b 1 %HELFER% check %WEB_PORT% if not errorlevel 1 ( echo Server laeuft bereits auf Port %WEB_PORT% - erst "run_web.bat stop". exit /b 1 ) if not exist "%PLATZ%\log" mkdir "%PLATZ%\log" echo Starte Web-Testinstanz im Hintergrund ... start "platz-web" /MIN cmd /c "call "%~dp0setenv.bat" > nul && call "%PLATZ%\.venv\Scripts\activate.bat" && python -m uvicorn main:app --reload --app-dir "%PLATZ%\web" --port %WEB_PORT% > "%PLATZ%\log\run_web.log" 2>&1" REM kurz warten und pruefen, ob der Server wirklich hochkommt REM (ping statt timeout: funktioniert auch ohne interaktive Konsole) ping -n 4 127.0.0.1 > nul %HELFER% check %WEB_PORT% if errorlevel 1 ( echo FEHLER: Server ist nicht gestartet - siehe %PLATZ%\log\run_web.log exit /b 1 ) echo Server laeuft: http://localhost:%WEB_PORT% ^(Logdatei: log\run_web.log^) exit /b 0 REM ---------------------------------------------------------------- :stop echo Beende alle uvicorn-Prozesse dieses Projekts auf Port %WEB_PORT% ... %HELFER% stop %WEB_PORT% exit /b 0 REM ---------------------------------------------------------------- :status %HELFER% status %WEB_PORT% exit /b %errorlevel% REM ---------------------------------------------------------------- :venv_pruefen if exist "%PLATZ%\.venv\Scripts\activate.bat" ( call "%PLATZ%\.venv\Scripts\activate.bat" exit /b 0 ) echo FEHLER: kein .venv gefunden - bitte zuerst bin\install_py.bat ausfuehren exit /b 1