From a6af4b155da1e60dc58dec15ecc88618ece5d042 Mon Sep 17 00:00:00 2001 From: FlechazoW Date: Mon, 28 Aug 2023 00:36:44 +0800 Subject: [PATCH] [Feature-#5258][Bin] Add .bat script for all shell script. --- .gitignore | 3 +- bin/install-plugin.cmd | 60 ++++++++++ config/seatunnel-env.cmd | 21 ++++ .../start-seatunnel-flink-13-connector-v2.cmd | 71 ++++++++++++ .../start-seatunnel-flink-15-connector-v2.cmd | 71 ++++++++++++ .../start-seatunnel-spark-2-connector-v2.cmd | 71 ++++++++++++ .../start-seatunnel-spark-3-connector-v2.cmd | 71 ++++++++++++ .../src/main/bin/seatunnel-cluster.cmd | 86 ++++++++++++++ .../src/main/bin/seatunnel-cluster.sh | 2 +- .../src/main/bin/seatunnel.cmd | 108 ++++++++++++++++++ .../src/main/bin/seatunnel.sh | 6 + .../src/main/bin/stop-seatunnel-cluster.cmd | 58 ++++++++++ 12 files changed, 626 insertions(+), 2 deletions(-) create mode 100644 bin/install-plugin.cmd create mode 100644 config/seatunnel-env.cmd create mode 100644 seatunnel-core/seatunnel-flink-starter/seatunnel-flink-13-starter/src/main/bin/start-seatunnel-flink-13-connector-v2.cmd create mode 100644 seatunnel-core/seatunnel-flink-starter/seatunnel-flink-15-starter/src/main/bin/start-seatunnel-flink-15-connector-v2.cmd create mode 100644 seatunnel-core/seatunnel-spark-starter/seatunnel-spark-2-starter/src/main/bin/start-seatunnel-spark-2-connector-v2.cmd create mode 100644 seatunnel-core/seatunnel-spark-starter/seatunnel-spark-3-starter/src/main/bin/start-seatunnel-spark-3-connector-v2.cmd create mode 100644 seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.cmd create mode 100644 seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.cmd create mode 100644 seatunnel-core/seatunnel-starter/src/main/bin/stop-seatunnel-cluster.cmd diff --git a/.gitignore b/.gitignore index 25977068e4fe..74311a0fa057 100644 --- a/.gitignore +++ b/.gitignore @@ -48,4 +48,5 @@ test.conf spark-warehouse *.flattened-pom.xml -seatunnel-examples \ No newline at end of file +seatunnel-examples +/lib/* \ No newline at end of file diff --git a/bin/install-plugin.cmd b/bin/install-plugin.cmd new file mode 100644 index 000000000000..4df77b968caf --- /dev/null +++ b/bin/install-plugin.cmd @@ -0,0 +1,60 @@ +@echo off +REM Licensed to the Apache Software Foundation (ASF) under one or more +REM contributor license agreements. See the NOTICE file distributed with +REM this work for additional information regarding copyright ownership. +REM The ASF licenses this file to You under the Apache License, Version 2.0 +REM (the "License"); you may not use this file except in compliance with +REM the License. You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. + +REM This script is used to download the connector plug-ins required during the running process. +REM All are downloaded by default. You can also choose what you need. +REM You only need to configure the plug-in name in config\plugin_config.txt. + +REM Get seatunnel home +set "SEATUNNEL_HOME=%~dp0..\" +echo Set SEATUNNEL_HOME to [%SEATUNNEL_HOME%] + +REM Connector default version is 2.3.3, you can also choose a custom version. eg: 2.1.2: install-plugin.bat 2.1.2 +set "version=2.3.3" +if not "%~1"=="" set "version=%~1" +echo Install hadoop shade jar, usage version is %version% + +REM Create the lib directory +if not exist "%SEATUNNEL_HOME%\lib" ( + mkdir "%SEATUNNEL_HOME%\lib" + echo create lib directory +) + +call "%SEATUNNEL_HOME%\mvnw.cmd" dependency:get -DgroupId="org.apache.seatunnel" -Dclassifier="optional" -DartifactId="seatunnel-hadoop3-3.1.4-uber" -Dversion="%version%" -Ddest="%SEATUNNEL_HOME%\lib" + +echo Install SeaTunnel connectors plugins, usage version is %version% + +REM Create the connectors directory +if not exist "%SEATUNNEL_HOME%\connectors" ( + mkdir "%SEATUNNEL_HOME%\connectors" + echo create connectors directory +) + +REM Create the seatunnel connectors directory (for v2) +if not exist "%SEATUNNEL_HOME%\connectors\seatunnel" ( + mkdir "%SEATUNNEL_HOME%\connectors\seatunnel" + echo create seatunnel connectors directory +) + +for /f "usebackq delims=" %%a in ("%SEATUNNEL_HOME%\config\plugin_config") do ( + set "line=%%a" + setlocal enabledelayedexpansion + if "!line:~0,1!" neq "-" if "!line:~0,1!" neq "#" ( + echo install connector : !line! + call "%SEATUNNEL_HOME%\mvnw.cmd" dependency:get -DgroupId="org.apache.seatunnel" -DartifactId="!line!" -Dversion="%version%" -Ddest="%SEATUNNEL_HOME%\connectors\seatunnel" + ) + endlocal +) diff --git a/config/seatunnel-env.cmd b/config/seatunnel-env.cmd new file mode 100644 index 000000000000..79c2d3c117c6 --- /dev/null +++ b/config/seatunnel-env.cmd @@ -0,0 +1,21 @@ +@echo off +REM Licensed to the Apache Software Foundation (ASF) under one or more +REM contributor license agreements. See the NOTICE file distributed with +REM this work for additional information regarding copyright ownership. +REM The ASF licenses this file to You under the Apache License, Version 2.0 +REM (the "License"); you may not use this file except in compliance with +REM the License. You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. + +REM Home directory of spark distribution. +if "%SPARK_HOME%" == "" set "SPARK_HOME=C:\Program Files\spark" + +REM Home directory of flink distribution. +if "%FLINK_HOME%" == "" set "FLINK_HOME=C:\Program Files\flink" \ No newline at end of file diff --git a/seatunnel-core/seatunnel-flink-starter/seatunnel-flink-13-starter/src/main/bin/start-seatunnel-flink-13-connector-v2.cmd b/seatunnel-core/seatunnel-flink-starter/seatunnel-flink-13-starter/src/main/bin/start-seatunnel-flink-13-connector-v2.cmd new file mode 100644 index 000000000000..c1cbc1d9556a --- /dev/null +++ b/seatunnel-core/seatunnel-flink-starter/seatunnel-flink-13-starter/src/main/bin/start-seatunnel-flink-13-connector-v2.cmd @@ -0,0 +1,71 @@ +@echo off +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +setlocal enabledelayedexpansion + +rem resolve links - %0 may be a softlink +set "PRG=%~f0" +:resolve_loop +rem Get the parent directory of the script +set "PRG_DIR=%~dp0" +rem Change current drive and directory to %PRG_DIR% and execute the 'dir' command, which will fail if %PRG% is not a valid file. +cd /d "%PRG_DIR%" || ( + echo Cannot determine the script's current directory. + exit /b 1 +) + +set "APP_DIR=%~dp0" +set "CONF_DIR=%APP_DIR%\config" +set "APP_JAR=%APP_DIR%\starter\seatunnel-flink-13-starter.jar" +set "APP_MAIN=org.apache.seatunnel.core.starter.flink.FlinkStarter" + +if exist "%CONF_DIR%\seatunnel-env.cmd" ( + call "%CONF_DIR%\seatunnel-env.cmd" +) + +if "%~1"=="" ( + set "args=-h" +) else ( + set "args=%*" +) + +set "JAVA_OPTS=" +rem Log4j2 Config +if exist "%CONF_DIR%\log4j2.properties" ( + set "JAVA_OPTS=!JAVA_OPTS! -Dlog4j2.configurationFile=%CONF_DIR%\log4j2.properties" + set "JAVA_OPTS=!JAVA_OPTS! -Dseatunnel.logs.path=%APP_DIR%\logs" + set "JAVA_OPTS=!JAVA_OPTS! -Dseatunnel.logs.file_name=seatunnel-flink-starter" +) + +set "CLASS_PATH=%APP_DIR%\starter\logging\*;%APP_JAR%" + +for /f "delims=" %%i in ('java %JAVA_OPTS% -cp %CLASS_PATH% %APP_MAIN% %args%') do ( + set "CMD=%%i" + setlocal disabledelayedexpansion + if !errorlevel! equ 234 ( + echo !CMD! + endlocal + exit /b 0 + ) else if !errorlevel! equ 0 ( + echo Execute SeaTunnel Flink Job: !CMD! + endlocal + call !CMD! + ) else ( + echo !CMD! + endlocal + exit /b !errorlevel! + ) +) diff --git a/seatunnel-core/seatunnel-flink-starter/seatunnel-flink-15-starter/src/main/bin/start-seatunnel-flink-15-connector-v2.cmd b/seatunnel-core/seatunnel-flink-starter/seatunnel-flink-15-starter/src/main/bin/start-seatunnel-flink-15-connector-v2.cmd new file mode 100644 index 000000000000..ed4c1f6979e1 --- /dev/null +++ b/seatunnel-core/seatunnel-flink-starter/seatunnel-flink-15-starter/src/main/bin/start-seatunnel-flink-15-connector-v2.cmd @@ -0,0 +1,71 @@ +@echo off +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +setlocal enabledelayedexpansion + +rem resolve links - %0 may be a softlink +set "PRG=%~f0" +:resolve_loop +rem Get the parent directory of the script +set "PRG_DIR=%~dp0" +rem Change current drive and directory to %PRG_DIR% and execute the 'dir' command, which will fail if %PRG% is not a valid file. +cd /d "%PRG_DIR%" || ( + echo Cannot determine the script's current directory. + exit /b 1 +) + +set "APP_DIR=%~dp0" +set "CONF_DIR=%APP_DIR%\config" +set "APP_JAR=%APP_DIR%\starter\seatunnel-flink-15-starter.jar" +set "APP_MAIN=org.apache.seatunnel.core.starter.flink.FlinkStarter" + +if exist "%CONF_DIR%\seatunnel-env.cmd" ( + call "%CONF_DIR%\seatunnel-env.cmd" +) + +if "%~1"=="" ( + set "args=-h" +) else ( + set "args=%*" +) + +set "JAVA_OPTS=" +rem Log4j2 Config +if exist "%CONF_DIR%\log4j2.properties" ( + set "JAVA_OPTS=!JAVA_OPTS! -Dlog4j2.configurationFile=%CONF_DIR%\log4j2.properties" + set "JAVA_OPTS=!JAVA_OPTS! -Dseatunnel.logs.path=%APP_DIR%\logs" + set "JAVA_OPTS=!JAVA_OPTS! -Dseatunnel.logs.file_name=seatunnel-flink-starter" +) + +set "CLASS_PATH=%APP_DIR%\starter\logging\*;%APP_JAR%" + +for /f "delims=" %%i in ('java %JAVA_OPTS% -cp %CLASS_PATH% %APP_MAIN% %args%') do ( + set "CMD=%%i" + setlocal disabledelayedexpansion + if !errorlevel! equ 234 ( + echo !CMD! + endlocal + exit /b 0 + ) else if !errorlevel! equ 0 ( + echo Execute SeaTunnel Flink Job: !CMD! + endlocal + call !CMD! + ) else ( + echo !CMD! + endlocal + exit /b !errorlevel! + ) +) diff --git a/seatunnel-core/seatunnel-spark-starter/seatunnel-spark-2-starter/src/main/bin/start-seatunnel-spark-2-connector-v2.cmd b/seatunnel-core/seatunnel-spark-starter/seatunnel-spark-2-starter/src/main/bin/start-seatunnel-spark-2-connector-v2.cmd new file mode 100644 index 000000000000..b2671671383a --- /dev/null +++ b/seatunnel-core/seatunnel-spark-starter/seatunnel-spark-2-starter/src/main/bin/start-seatunnel-spark-2-connector-v2.cmd @@ -0,0 +1,71 @@ +@echo off +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +setlocal enabledelayedexpansion + +rem resolve links - %0 may be a softlink +set "PRG=%~f0" +:resolve_loop +rem Get the parent directory of the script +set "PRG_DIR=%~dp0" +rem Change current drive and directory to %PRG_DIR% and execute the 'dir' command, which will fail if %PRG% is not a valid file. +cd /d "%PRG_DIR%" || ( + echo Cannot determine the script's current directory. + exit /b 1 +) + +set "APP_DIR=%~dp0" +set "CONF_DIR=%APP_DIR%\config" +set "APP_JAR=%APP_DIR%\starter\seatunnel-spark-2-starter.jar" +set "APP_MAIN=org.apache.seatunnel.core.starter.spark.SparkStarter" + +if exist "%CONF_DIR%\seatunnel-env.cmd" ( + call "%CONF_DIR%\seatunnel-env.cmd" +) + +if "%~1"=="" ( + set "args=-h" +) else ( + set "args=%*" +) + +set "JAVA_OPTS=" +rem Log4j2 Config +if exist "%CONF_DIR%\log4j2.properties" ( + set "JAVA_OPTS=!JAVA_OPTS! -Dlog4j2.configurationFile=%CONF_DIR%\log4j2.properties" + set "JAVA_OPTS=!JAVA_OPTS! -Dseatunnel.logs.path=%APP_DIR%\logs" + set "JAVA_OPTS=!JAVA_OPTS! -Dseatunnel.logs.file_name=seatunnel-spark-starter" +) + +set "CLASS_PATH=%APP_DIR%\starter\logging\*;%APP_JAR%" + +for /f "delims=" %%i in ('java %JAVA_OPTS% -cp %CLASS_PATH% %APP_MAIN% %args%') do ( + set "CMD=%%i" + setlocal disabledelayedexpansion + if !errorlevel! equ 234 ( + echo !CMD! + endlocal + exit /b 0 + ) else if !errorlevel! equ 0 ( + echo Execute SeaTunnel Spark Job: !CMD! + endlocal + call !CMD! + ) else ( + echo !CMD! + endlocal + exit /b !errorlevel! + ) +) diff --git a/seatunnel-core/seatunnel-spark-starter/seatunnel-spark-3-starter/src/main/bin/start-seatunnel-spark-3-connector-v2.cmd b/seatunnel-core/seatunnel-spark-starter/seatunnel-spark-3-starter/src/main/bin/start-seatunnel-spark-3-connector-v2.cmd new file mode 100644 index 000000000000..433fe23c6d19 --- /dev/null +++ b/seatunnel-core/seatunnel-spark-starter/seatunnel-spark-3-starter/src/main/bin/start-seatunnel-spark-3-connector-v2.cmd @@ -0,0 +1,71 @@ +@echo off +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +setlocal enabledelayedexpansion + +rem resolve links - %0 may be a softlink +set "PRG=%~f0" +:resolve_loop +rem Get the parent directory of the script +set "PRG_DIR=%~dp0" +rem Change current drive and directory to %PRG_DIR% and execute the 'dir' command, which will fail if %PRG% is not a valid file. +cd /d "%PRG_DIR%" || ( + echo Cannot determine the script's current directory. + exit /b 1 +) + +set "APP_DIR=%~dp0" +set "CONF_DIR=%APP_DIR%\config" +set "APP_JAR=%APP_DIR%\starter\seatunnel-spark-3-starter.jar" +set "APP_MAIN=org.apache.seatunnel.core.starter.spark.SparkStarter" + +if exist "%CONF_DIR%\seatunnel-env.cmd" ( + call "%CONF_DIR%\seatunnel-env.cmd" +) + +if "%~1"=="" ( + set "args=-h" +) else ( + set "args=%*" +) + +set "JAVA_OPTS=" +rem Log4j2 Config +if exist "%CONF_DIR%\log4j2.properties" ( + set "JAVA_OPTS=!JAVA_OPTS! -Dlog4j2.configurationFile=%CONF_DIR%\log4j2.properties" + set "JAVA_OPTS=!JAVA_OPTS! -Dseatunnel.logs.path=%APP_DIR%\logs" + set "JAVA_OPTS=!JAVA_OPTS! -Dseatunnel.logs.file_name=seatunnel-spark-starter" +) + +set "CLASS_PATH=%APP_DIR%\starter\logging\*;%APP_JAR%" + +for /f "delims=" %%i in ('java %JAVA_OPTS% -cp %CLASS_PATH% %APP_MAIN% %args%') do ( + set "CMD=%%i" + setlocal disabledelayedexpansion + if !errorlevel! equ 234 ( + echo !CMD! + endlocal + exit /b 0 + ) else if !errorlevel! equ 0 ( + echo Execute SeaTunnel Spark Job: !CMD! + endlocal + call !CMD! + ) else ( + echo !CMD! + endlocal + exit /b !errorlevel! + ) +) diff --git a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.cmd b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.cmd new file mode 100644 index 000000000000..e94a4bb482fa --- /dev/null +++ b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.cmd @@ -0,0 +1,86 @@ +@echo off +REM Licensed to the Apache Software Foundation (ASF) under one or more +REM contributor license agreements. See the NOTICE file distributed with +REM this work for additional information regarding copyright ownership. +REM The ASF licenses this file to You under the Apache License, Version 2.0 +REM (the "License"); you may not use this file except in compliance with +REM the License. You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. + +setlocal enabledelayedexpansion + +REM resolve links - %0 may be a softlink +for %%F in ("%~f0") do ( + set "PRG=%%~fF" + set "PRG_DIR=%%~dpF" + set "APP_DIR=%%~dpF.." +) + +set "CONF_DIR=%APP_DIR%\config" +set "APP_JAR=%APP_DIR%\starter\seatunnel-starter.jar" +set "APP_MAIN=org.apache.seatunnel.core.starter.seatunnel.SeaTunnelServer" +set "OUT=%APP_DIR%\logs\seatunnel-server.out" + +set "HELP=false" +set "args=" + +for %%I in (%*) do ( + set "args=!args! %%I" + if "%%I"=="-d" set "DAEMON=true" + if "%%I"=="--daemon" set "DAEMON=true" + if "%%I"=="-h" set "HELP=true" + if "%%I"=="--help" set "HELP=true" +) + +REM SeaTunnel Engine Config +set "HAZELCAST_CONFIG=%CONF_DIR%\hazelcast.yaml" +set "SEATUNNEL_CONFIG=%CONF_DIR%\seatunnel.yaml" +set "JAVA_OPTS=%JvmOption%" + +for %%I in (%*) do ( + set "arg=%%I" + if "!arg:~0,10!"=="JvmOption=" ( + set "JAVA_OPTS=%JAVA_OPTS% !arg:~10!" + ) +) + +set "JAVA_OPTS=%JAVA_OPTS% -Dseatunnel.config=%SEATUNNEL_CONFIG%" +set "JAVA_OPTS=%JAVA_OPTS% -Dhazelcast.config=%HAZELCAST_CONFIG%" +set "JAVA_OPTS=%JAVA_OPTS% -Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector" + +REM Server Debug Config +REM Usage instructions: +REM If you need to debug your code in cluster mode, please enable this configuration option and listen to the specified +REM port in your IDE. After that, you can happily debug your code. +REM set "JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=5001,suspend=y" + +if exist "%CONF_DIR%\log4j2.properties" ( + set "JAVA_OPTS=%JAVA_OPTS% -Dlog4j2.configurationFile=%CONF_DIR%\log4j2.properties" + set "JAVA_OPTS=%JAVA_OPTS% -Dseatunnel.logs.path=%APP_DIR%\logs" + set "JAVA_OPTS=%JAVA_OPTS% -Dseatunnel.logs.file_name=seatunnel-engine-server" +) + +set "CLASS_PATH=%APP_DIR%\lib\*;%APP_JAR%" + +for /f "usebackq delims=" %%I in ("%APP_DIR%\config\jvm_options") do ( + set "line=%%I" + if not "!line:~0,1!"=="#" if "!line!" NEQ "" ( + set "JAVA_OPTS=!JAVA_OPTS! !line!" + ) +) + +if "%HELP%"=="false" ( + if not exist "%APP_DIR%\logs\" mkdir "%APP_DIR%\logs" + start "SeaTunnel Server" java %JAVA_OPTS% -cp "%CLASS_PATH%" %APP_MAIN% %args% > "%OUT%" 2>&1 +) else ( + java %JAVA_OPTS% -cp "%CLASS_PATH%" %APP_MAIN% %args% +) + +endlocal \ No newline at end of file diff --git a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.sh b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.sh index d4644f2d4dae..e85a97e67a4b 100755 --- a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.sh +++ b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.sh @@ -93,7 +93,7 @@ fi # Usage instructions: # If you need to debug your code in cluster mode, please enable this configuration option and listen to the specified # port in your IDE. After that, you can happily debug your code. -# JAVA_OPTS="${JAVA_OPTS} -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n" +# JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=5001,suspend=y" CLASS_PATH=${APP_DIR}/lib/*:${APP_JAR} diff --git a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.cmd b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.cmd new file mode 100644 index 000000000000..cf9258e9d50b --- /dev/null +++ b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.cmd @@ -0,0 +1,108 @@ +@echo off +REM Licensed to the Apache Software Foundation (ASF) under one or more +REM contributor license agreements. See the NOTICE file distributed with +REM this work for additional information regarding copyright ownership. +REM The ASF licenses this file to You under the Apache License, Version 2.0 +REM (the "License"); you may not use this file except in compliance with +REM the License. You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. + +setlocal enabledelayedexpansion +REM resolve links - %0 may be a softlink +set "PRG=%~0" + +:resolveLoop +for %%F in ("%PRG%") do ( + set "PRG_DIR=%%~dpF" + set "PRG_NAME=%%~nxF" +) +set "PRG=%PRG_DIR%%PRG_NAME%" + +REM Get application directory +cd "%PRG_DIR%\.." +set "APP_DIR=%CD%" + +set "CONF_DIR=%APP_DIR%\config" +set "APP_JAR=%APP_DIR%\starter\seatunnel-starter.jar" +set "APP_MAIN=org.apache.seatunnel.core.starter.seatunnel.SeaTunnelClient" + +if exist "%CONF_DIR%\seatunnel-env.cmd" call "%CONF_DIR%\seatunnel-env.cmd" + +if "%~1"=="" ( + set "args=-h" +) else ( + set "args=%*" +) + +REM SeaTunnel Engine Config +if not defined HAZELCAST_CLIENT_CONFIG ( + set "HAZELCAST_CLIENT_CONFIG=%CONF_DIR%\hazelcast-client.yaml" +) + +if not defined HAZELCAST_CONFIG ( + set "HAZELCAST_CONFIG=%CONF_DIR%\hazelcast.yaml" +) + +if not defined SEATUNNEL_CONFIG ( + set "SEATUNNEL_CONFIG=%CONF_DIR%\seatunnel.yaml" +) + +if defined JvmOption ( + set "JAVA_OPTS=%JAVA_OPTS% %JvmOption%" +) + +for %%i in (%*) do ( + set "arg=%%i" + if "!arg:~0,9!"=="JvmOption" ( + set "JVM_OPTION=!arg:~9!" + set "JAVA_OPTS=!JAVA_OPTS! !JVM_OPTION!" + goto :break_loop + ) +) +:break_loop + +set "JAVA_OPTS=%JAVA_OPTS% -Dhazelcast.client.config=%HAZELCAST_CLIENT_CONFIG%" +set "JAVA_OPTS=%JAVA_OPTS% -Dseatunnel.config=%SEATUNNEL_CONFIG%" +set "JAVA_OPTS=%JAVA_OPTS% -Dhazelcast.config=%HAZELCAST_CONFIG%" + +REM if you want to debug, please +REM set "JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=5000,suspend=y" + +REM Log4j2 Config +if exist "%CONF_DIR%\log4j2_client.properties" ( + set "JAVA_OPTS=%JAVA_OPTS% -Dlog4j2.configurationFile=%CONF_DIR%\log4j2_client.properties" + set "JAVA_OPTS=%JAVA_OPTS% -Dseatunnel.logs.path=%APP_DIR%\logs" + for %%i in (%args%) do ( + set "arg=%%i" + if "!arg!"=="-m" set "is_local_mode=true" + if "!arg!"=="--master" set "is_local_mode=true" + if "!arg!"=="-e" set "is_local_mode=true" + if "!arg!"=="--deploy-mode" set "is_local_mode=true" + ) + if defined is_local_mode ( + for /f "tokens=1-3 delims=:" %%A in ('echo %time%') do ( + set "ntime=%%A%%B%%C" + ) + set "JAVA_OPTS=%JAVA_OPTS% -Dseatunnel.logs.file_name=seatunnel-starter-client-!date:~0,4!!date:~5,2!!date:~8,2!-!time:~0,2!!time:~3,2!!time:~6,2!!ntime!" + ) else ( + set "JAVA_OPTS=%JAVA_OPTS% -Dseatunnel.logs.file_name=seatunnel-starter-client" + ) +) + +set "CLASS_PATH=%APP_DIR%\lib\*;%APP_JAR%" + +for /f "usebackq delims=" %%a in ("%APP_DIR%\config\jvm_client_options") do ( + set "line=%%a" + if not "!line:~0,1!"=="#" if "!line!" neq "" ( + set "JAVA_OPTS=!JAVA_OPTS! !line!" + ) +) + +java %JAVA_OPTS% -cp %CLASS_PATH% %APP_MAIN% %args% diff --git a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh index 7c25ec126c0e..b95800f1c2c2 100755 --- a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh +++ b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh @@ -81,6 +81,12 @@ JAVA_OPTS="${JAVA_OPTS} -Dhazelcast.client.config=${HAZELCAST_CLIENT_CONFIG}" JAVA_OPTS="${JAVA_OPTS} -Dseatunnel.config=${SEATUNNEL_CONFIG}" JAVA_OPTS="${JAVA_OPTS} -Dhazelcast.config=${HAZELCAST_CONFIG}" +# Client Debug Config +# Usage instructions: +# If you need to debug your code in cluster mode, please enable this configuration option and listen to the specified +# port in your IDE. After that, you can happily debug your code. +# JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=5000,suspend=y" + # Log4j2 Config if [ -e "${CONF_DIR}/log4j2_client.properties" ]; then JAVA_OPTS="${JAVA_OPTS} -Dlog4j2.configurationFile=${CONF_DIR}/log4j2_client.properties" diff --git a/seatunnel-core/seatunnel-starter/src/main/bin/stop-seatunnel-cluster.cmd b/seatunnel-core/seatunnel-starter/src/main/bin/stop-seatunnel-cluster.cmd new file mode 100644 index 000000000000..0c0cb72b0144 --- /dev/null +++ b/seatunnel-core/seatunnel-starter/src/main/bin/stop-seatunnel-cluster.cmd @@ -0,0 +1,58 @@ +@echo off +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +setlocal enabledelayedexpansion + +set "SEATUNNEL_DEFAULT_CLUSTER_NAME=seatunnel_default_cluster" +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" +set "APP_MAIN=org.apache.seatunnel.core.starter.seatunnel.SeaTunnelServer" +set "CLUSTER_NAME=" + +if "%~1"=="" ( + echo !SHOW_USAGE! + exit /B 1 +) + +:parse_args +if "%~1"=="-cn" ( + shift + set "CLUSTER_NAME=%~1" + shift + goto :parse_args +) else if "%~1"=="--cluster" ( + shift + set "CLUSTER_NAME=%~1" + shift + goto :parse_args +) else if "%~1"=="-h" ( + echo !SHOW_USAGE! + exit /B 0 +) else if "%~1"=="--help" ( + echo !SHOW_USAGE! + exit /B 0 +) + +if not defined CLUSTER_NAME ( + for /f %%i in ('tasklist /fi "imagename eq java.exe" ^| find "!APP_MAIN!"') do ( + taskkill /F /PID %%i + ) +) else ( + for /f %%i in ('tasklist /fi "imagename eq java.exe" ^| find "!APP_MAIN!" ^| find "!CLUSTER_NAME!"') do ( + taskkill /F /PID %%i + ) +) + +exit /B 0 \ No newline at end of file