-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkill_process.bat
More file actions
153 lines (135 loc) · 4.06 KB
/
Copy pathkill_process.bat
File metadata and controls
153 lines (135 loc) · 4.06 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion
:MENU
cls
echo ========================================================
echo S14P11A107 System Terminator (Killer)
echo ========================================================
echo.
echo [ vLLM Engine ]
echo 1. Kill vLLM Engine A (Port 8002)
echo 2. Kill vLLM Engine B (Port 8001)
echo.
echo [ Backend Service ]
echo 3. Kill Service A (Port 50051)
echo 4. Kill Service B (Port 9900)
echo.
echo [ Ngrok Tunnel ]
echo 5. Kill Ngrok Tunnel A
echo 6. Kill Ngrok Tunnel B
echo.
echo [ ETC ]
echo 7. ALL KILL (전체 종료)
echo 8. Docker 컨테이너 모두 종료
echo 0. 나가기 (Exit)
echo.
echo ========================================================
echo 사용법: 번호를 공백으로 구분하여 입력 (예: 1 3 6)
echo 팁: 전체를 끄려면 7번만 입력하세요.
echo.
set /p selection="종료할 번호 입력 >> "
:: 0 입력 시 종료
if "%selection%"=="0" goto :EOF
echo.
echo [시스템 종료 프로세스 시작...]
echo --------------------------------------------------------
:: 7 입력 시 전체 종료로 변환
if "%selection%"=="7" (
call :KILL_PROCESS 1
call :KILL_PROCESS 2
call :KILL_PROCESS 3
call :KILL_PROCESS 4
call :KILL_PROCESS 5
call :KILL_PROCESS 6
call :KILL_PROCESS 8
goto :DONE
)
:: 입력된 숫자들을 개별 처리
for %%i in (%selection%) do (
call :KILL_PROCESS %%i
)
:DONE
echo --------------------------------------------------------
echo 모든 요청 작업이 완료되었습니다.
pause
goto :MENU
:: =================================================
:: 실제 종료 로직 함수 (포트 기반 종료)
:: =================================================
:KILL_PROCESS
set target=%1
if "%target%"=="1" (
echo [Target: 1] vLLM Engine A 종료 중 (Docker + Port 8002^)...
call :KILL_DOCKER_BY_PORT 8002
goto :EOF
)
if "%target%"=="2" (
echo [Target: 2] vLLM Engine B 종료 중 (Docker + Port 8001^)...
call :KILL_DOCKER_BY_PORT 8001
goto :EOF
)
if "%target%"=="3" (
echo [Target: 3] Service A 종료 중 (Python + Port 50051^)...
call :KILL_PYTHON_BY_PORT 50051
goto :EOF
)
if "%target%"=="4" (
echo [Target: 4] Service B 종료 중 (Python + Port 9900^)...
call :KILL_PYTHON_BY_PORT 9900
goto :EOF
)
if "%target%"=="5" (
echo [Target: 5] Ngrok A 종료 중...
taskkill /F /FI "WINDOWTITLE eq Ngrok A*" 2>nul
taskkill /F /IM ngrok.exe 2>nul
goto :EOF
)
if "%target%"=="6" (
echo [Target: 6] Ngrok B 종료 중...
taskkill /F /FI "WINDOWTITLE eq Ngrok B*" 2>nul
taskkill /F /IM ngrok.exe 2>nul
goto :EOF
)
if "%target%"=="8" (
echo [Target: 8] Docker 컨테이너 모두 종료 중...
call :KILL_ALL_DOCKER
goto :EOF
)
goto :EOF
:: =================================================
:: Docker 컨테이너 종료 (포트 기반)
:: =================================================
:KILL_DOCKER_BY_PORT
set port=%1
echo - Docker 컨테이너 검색 중 (Port %port%^)...
for /f "delims=" %%i in ('docker ps -q --filter "publish=%port%" 2^>nul') do (
echo - 컨테이너 종료: %%i
docker stop %%i 2>nul
)
goto :EOF
:: =================================================
:: 모든 Docker 컨테이너 종료
:: =================================================
:KILL_ALL_DOCKER
for /f "delims=" %%i in ('docker ps -q 2^>nul') do (
echo - 컨테이너 종료: %%i
docker stop %%i 2>nul
)
goto :EOF
:: =================================================
:: Python 프로세스 종료 (포트 + 프로세스 이름 필터)
:: =================================================
:KILL_PYTHON_BY_PORT
set port=%1
echo - Python 프로세스 검색 중 (Port %port%^)...
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":%port%" ^| findstr "LISTENING"') do (
set pid=%%a
if not "!pid!"=="0" (
for /f "tokens=1" %%b in ('tasklist /FI "PID eq !pid!" /FO CSV /NH 2^>nul ^| findstr /I "python"') do (
echo - Python 프로세스 종료: PID !pid!
taskkill /F /PID !pid! /T 2>nul
)
)
)
goto :EOF