fix: ethend.bat 启动时统一走端口检测+Y/n交互

This commit is contained in:
2026-06-28 16:53:02 +08:00
parent 6cbb3e3e80
commit 3b8b35069a
+2 -10
View File
@@ -117,16 +117,7 @@ if %DO_FRESH%==1 (
curl -s -X POST "http://localhost:%ETHEND_PORT%/api/services/start-all-fresh" >nul 2>&1 curl -s -X POST "http://localhost:%ETHEND_PORT%/api/services/start-all-fresh" >nul 2>&1
) )
:: Check if already running :: Check if port already in use
curl -s -o nul "http://localhost:%ETHEND_PORT%/api/health" 2>nul
if %ERRORLEVEL%==0 (
echo.
echo [OK] ethend already running: http://localhost:%ETHEND_PORT%
echo API: http://localhost:%ETHEND_PORT%/api/health
exit /b 0
)
:: Check port conflict
set FOUND_PID= set FOUND_PID=
for /f "tokens=5" %%a in ('netstat -ano ^| findstr /R ":%ETHEND_PORT% " ^| findstr "LISTENING"') do set FOUND_PID=%%a for /f "tokens=5" %%a in ('netstat -ano ^| findstr /R ":%ETHEND_PORT% " ^| findstr "LISTENING"') do set FOUND_PID=%%a
if not "%FOUND_PID%"=="" ( if not "%FOUND_PID%"=="" (
@@ -135,6 +126,7 @@ if not "%FOUND_PID%"=="" (
set /p CHOICE="Kill old process and restart? [Y/n]: " set /p CHOICE="Kill old process and restart? [Y/n]: "
if /i "!CHOICE!"=="n" ( if /i "!CHOICE!"=="n" (
echo [INFO] Aborted by user. echo [INFO] Aborted by user.
pause
exit /b 0 exit /b 0
) )
echo [INFO] Killing PID %FOUND_PID%... echo [INFO] Killing PID %FOUND_PID%...