Skip to content

Commit f36cb26

Browse files
committed
fix stop cluster not work on windows
1 parent 9d201bb commit f36cb26

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

seatunnel-core/seatunnel-starter/src/main/bin/stop-seatunnel-cluster.cmd

+10-15
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ rem limitations under the License.
1616

1717
setlocal enabledelayedexpansion
1818

19-
set "SEATUNNEL_DEFAULT_CLUSTER_NAME=seatunnel_default_cluster"
20-
set "SHOW_USAGE=Usage: stop-seatunnel-cluster.bat \n Options: \n -cn, --cluster The name of the cluster to shut down (default: $SEATUNNEL_DEFAULT_CLUSTER_NAME) \n -h, --help Show the usage message"
19+
set "SHOW_USAGE=Usage: stop-seatunnel-cluster.bat \n Options: \n -cn, --cluster The name of the cluster to shut down\n -h, --help Show the usage message"
2120
set "APP_MAIN=org.apache.seatunnel.core.starter.seatunnel.SeaTunnelServer"
2221
set "CLUSTER_NAME="
2322

2423
if "%~1"=="" (
25-
echo !SHOW_USAGE!
26-
exit /B 1
24+
set "query=commandline like '%%%%!APP_MAIN!%%%%' AND name ^!= 'wmic.exe'"
25+
wmic process where "!query!" delete
26+
exit /B 0
2727
)
2828

2929
:parse_args
3030
if "%~1"=="-cn" (
3131
shift
32-
set "CLUSTER_NAME=%~1"
32+
set "CLUSTER_NAME=%~2"
3333
shift
3434
goto :parse_args
3535
) else if "%~1"=="--cluster" (
3636
shift
37-
set "CLUSTER_NAME=%~1"
37+
set "CLUSTER_NAME=%~2"
3838
shift
3939
goto :parse_args
4040
) else if "%~1"=="-h" (
@@ -45,14 +45,9 @@ if "%~1"=="-cn" (
4545
exit /B 0
4646
)
4747

48-
if not defined CLUSTER_NAME (
49-
for /f %%i in ('tasklist /fi "imagename eq java.exe" ^| find "!APP_MAIN!"') do (
50-
taskkill /F /PID %%i
51-
)
52-
) else (
53-
for /f %%i in ('tasklist /fi "imagename eq java.exe" ^| find "!APP_MAIN!" ^| find "!CLUSTER_NAME!"') do (
54-
taskkill /F /PID %%i
55-
)
56-
)
48+
49+
set "query=(commandline like '%%%%-cn !CLUSTER_NAME!%%%%' OR commandline like '%%%%--cluster !CLUSTER_NAME!%%%%') AND commandline like '%%%%!APP_MAIN!%%%%' AND name ^!= 'wmic.exe'"
50+
51+
wmic process where "!query!" delete
5752

5853
exit /B 0

0 commit comments

Comments
 (0)