feat: FastAPI+SSE API server, JRXML auto-reorder, session integrity fixes

This commit is contained in:
2026-05-22 17:53:59 +08:00
parent 1144a86d02
commit 1e5ce9725b
32 changed files with 9189 additions and 309 deletions
+38 -44
View File
@@ -1,53 +1,47 @@
@echo off
setlocal enabledelayedexpansion
echo ================================================
echo agent_jrxml 启动 (API + 验证)
echo ================================================
cd /d "%~dp0"
echo ============================================
echo JRXML Agent - One-Click Start
echo ============================================
echo.
REM ========== Kill processes on ports ==========
echo [Pre-check] Cleaning up occupied ports...
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":8001.*LISTENING" 2^>nul') do (
echo Killing PID %%a on port 8001...
taskkill /PID %%a /F 2>nul
:: 清理残留进程
echo [清理] 检查残留进程...
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":8000.*LISTENING"') do (
taskkill /F /PID %%a >nul 2>&1 && echo 已清理 PID %%a
)
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":8000.*LISTENING" 2^>nul') do (
echo Killing PID %%a on port 8000...
taskkill /PID %%a /F 2>nul
)
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":5173.*LISTENING" 2^>nul') do (
echo Killing PID %%a on port 5173...
taskkill /PID %%a /F 2>nul
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":8001.*LISTENING"') do (
taskkill /F /PID %%a >nul 2>&1 && echo 已清理 PID %%a
)
echo.
REM ========== Detect Python ==========
set PYTHON=python
if exist "%~dp0.venv\Scripts\python.exe" set "PYTHON=%~dp0.venv\Scripts\python.exe"
echo Using Python: %PYTHON%
:: 启动验证服务 (后台最小化)
echo [启动] 验证服务 :8001
start "jrxml-validator" /MIN .venv\Scripts\python.exe -c "import uvicorn; uvicorn.run('validation_service.main:app',host='0.0.0.0',port=8001,reload=False)"
:: 等待验证服务就绪 (用 PowerShell 检测)
echo [等待] 验证服务就绪...
:wait_val
ping -n 2 127.0.0.1 >nul
powershell -Command "try{$r=Invoke-WebRequest -Uri http://localhost:8001/health -TimeoutSec 2 -UseBasicParsing;exit 0}catch{exit 1}" >nul 2>&1
if errorlevel 1 goto wait_val
echo :8001 就绪
:: 启动 API 服务 (前台,Ctrl+C 退出)
echo [启动] API 服务 :8000
echo ================================================
echo 服务已就绪:
echo API: http://localhost:8000/docs
echo 验证: http://localhost:8001/health
echo 按 Ctrl+C 停止 API 服务
echo 关闭窗口后会自动清理验证服务
echo ================================================
.venv\Scripts\python.exe -c "import uvicorn; uvicorn.run('api_server:app',host='0.0.0.0',port=8000,reload=False)"
:: API 进程退出后自动清理
echo.
REM ========== Start services ==========
echo [1/3] Starting validation service on port 8001...
start "JRXML-Validator" cmd /k cd /d "%~dp0" ^&^& "%PYTHON%" -m uvicorn validation_service.main:app --port 8001 --host 0.0.0.0
timeout /t 3 /nobreak >nul
echo [2/3] Starting backend API on port 8000...
start "JRXML-API" cmd /k cd /d "%~dp0" ^&^& "%PYTHON%" -m uvicorn api_server:app --port 8000 --host 0.0.0.0
timeout /t 3 /nobreak >nul
echo [3/3] Starting frontend dev server on port 5173...
start "JRXML-Frontend" cmd /k cd /d "%~dp0frontend" ^&^& npm run dev
timeout /t 3 /nobreak >nul
echo.
echo ============================================
echo All services started!
echo Frontend : http://localhost:5173
echo Backend : http://localhost:8000
echo Validator : http://localhost:8001
echo ============================================
echo.
echo Close the service windows or run stop.bat to stop.
echo [清理] 停止验证服务...
taskkill /F /FI "WINDOWTITLE eq jrxml-validator*" >nul 2>&1
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":8001.*LISTENING"') do taskkill /F /PID %%a >nul 2>&1
echo 已停止所有服务
pause