fix: ethend.bat 端口占用时询问用户是否Kill旧进程

This commit is contained in:
2026-06-28 16:46:35 +08:00
parent f95f7d67e3
commit 350cd105bf
+10 -3
View File
@@ -122,11 +122,18 @@ if %ERRORLEVEL%==0 (
exit /b 0
)
:: Free port
:: Check port conflict and ask user
for /f "tokens=5" %%a in ('netstat -ano ^| findstr /R ":%ETHEND_PORT% " ^| findstr "LISTENING"') do (
echo [WARN] Port %ETHEND_PORT% in use by PID %%a, releasing...
echo.
echo [WARN] Port %ETHEND_PORT% is in use by PID %%a.
set /p CHOICE="Kill old process and restart? [Y/n]: "
if /i "!CHOICE!"=="n" (
echo [INFO] Aborted by user.
exit /b 0
)
echo [INFO] Killing PID %%a...
taskkill /PID %%a /F >nul 2>&1
timeout /t 1 /nobreak >nul
timeout /t 2 /nobreak >nul
)
cd /d "%ETHEND_DIR%"