-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstop.bat
More file actions
46 lines (40 loc) · 1.15 KB
/
Copy pathstop.bat
File metadata and controls
46 lines (40 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
@echo off
title ZCode2API Stop
cd /d "%~dp0"
echo ========================================================
echo Stopping ZCode2API
echo ========================================================
echo.
set STOPPED=0
if exist "%~dp0zcode2api.pid" (
set /p RUN_PID=<"%~dp0zcode2api.pid"
if defined RUN_PID (
echo [*] Stopping process PID %RUN_PID%...
taskkill /F /T /PID %RUN_PID% >nul 2>&1
if not errorlevel 1 set STOPPED=1
)
del /f /q "%~dp0zcode2api.pid" >nul 2>&1
)
if exist "%~dp0zcode2api.port" (
set /p RUN_PORT=<"%~dp0zcode2api.port"
del /f /q "%~dp0zcode2api.port" >nul 2>&1
) else (
set RUN_PORT=3335
)
if defined RUN_PORT (
echo [*] Checking port %RUN_PORT%...
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":%RUN_PORT% " ^| findstr "LISTENING"') do (
echo [*] Killing process on port %RUN_PORT%: PID %%a
taskkill /F /T /PID %%a >nul 2>&1
set STOPPED=1
)
)
echo.
if "%STOPPED%"=="1" (
echo [OK] ZCode2API has been stopped.
) else (
echo [*] No running ZCode2API process found.
)
echo ========================================================
echo.
pause