You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by ga...@apache.org on 2023/03/20 10:43:10 UTC

[incubator-seatunnel] branch dev updated: [Improve][Seatunnel-Cluster] Run the server through daemon (#4161)

This is an automated email from the ASF dual-hosted git repository.

gaojun2048 pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-seatunnel.git


The following commit(s) were added to refs/heads/dev by this push:
     new 40699b660 [Improve][Seatunnel-Cluster] Run the server through  daemon (#4161)
40699b660 is described below

commit 40699b660cfecb5cffb2da0a94dc1bbd29a19579
Author: Guangdong Liu <80...@qq.com>
AuthorDate: Mon Mar 20 18:43:04 2023 +0800

    [Improve][Seatunnel-Cluster] Run the server through  daemon (#4161)
    
    * Add Support SeaTunnel Zeta Cluster Node Run Through A Daemon
---
 docs/en/seatunnel-engine/deployment.md                     |  4 +++-
 release-note.md                                            |  1 +
 .../seatunnel-starter/src/main/bin/seatunnel-cluster.sh    | 14 ++++++++++++--
 .../core/starter/seatunnel/args/ServerCommandArgs.java     |  5 +++++
 4 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/docs/en/seatunnel-engine/deployment.md b/docs/en/seatunnel-engine/deployment.md
index c6e09669f..be38ac2db 100644
--- a/docs/en/seatunnel-engine/deployment.md
+++ b/docs/en/seatunnel-engine/deployment.md
@@ -224,9 +224,11 @@ hazelcast-client:
 
 ## 7. Start SeaTunnel Engine Server Node
 
+Can be started by a daemon with `-d`.
+
 ```shell
 mkdir -p $SEATUNNEL_HOME/logs
-nohup bin/seatunnel-cluster.sh 2>&1 &
+./bin/seatunnel-cluster.sh -d
 ```
 
 The logs will write in `$SEATUNNEL_HOME/logs/seatunnel-engine-server.log`
diff --git a/release-note.md b/release-note.md
index c08662b32..004d04eb8 100644
--- a/release-note.md
+++ b/release-note.md
@@ -5,6 +5,7 @@
 - [Script]Add support close engine instance shell
 - [Client]Add Zeta Client ShutdownHook To Cancel Job
 - [Script]Add a jvm.properties file to define the SeaTunnel Zeta JVM Options
+- [Script] Run the server through daemon #4161
 ### Core
 - [Starter][Flink]Support transform-v2 for flink #3396
 - [Flink] Support flink 1.14.x #3963
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 3ae22cb24..0d97a5f5e 100755
--- a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.sh
+++ b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.sh
@@ -38,6 +38,7 @@ APP_DIR=`cd "$PRG_DIR/.." >/dev/null; pwd`
 CONF_DIR=${APP_DIR}/config
 APP_JAR=${APP_DIR}/starter/seatunnel-starter.jar
 APP_MAIN="org.apache.seatunnel.core.starter.seatunnel.SeaTunnelServer"
+OUT="${APP_DIR}/logs/seatunnel-server.out"
 
 if [ -f "${CONF_DIR}/seatunnel-env.sh" ]; then
     . "${CONF_DIR}/seatunnel-env.sh"
@@ -69,7 +70,10 @@ do
   if [[ "${i}" == *"JvmOption"* ]]; then
     JVM_OPTION="${i}"
     JAVA_OPTS="${JAVA_OPTS} ${JVM_OPTION#*=}"
-    break
+  elif [[ "${i}" == "-d" || "${i}" == "--daemon" ]]; then
+    DAEMON=true
+  elif [[ "${i}" == "-h" || "${i}" == "--help" ]]; then
+    HELP=true
   fi
 done
 
@@ -92,4 +96,10 @@ JVM_OPTIONS=`java -cp ${CLASS_PATH} org.apache.seatunnel.core.starter.seatunnel.
 JAVA_OPTS="${JAVA_OPTS} ${JVM_OPTIONS//\$\{loggc\}/${ST_TMPDIR}}"
 echo "JAVA_OPTS:" ${JAVA_OPTS}
 
-java ${JAVA_OPTS} -cp ${CLASS_PATH} ${APP_MAIN} ${args}
+if [[ $DAEMON == true && $HELP == false ]]; then
+ touch $SEATUNNEL_HOME/logs/seatunnel-server.out
+ java ${JAVA_OPTS} -cp ${CLASS_PATH} ${APP_MAIN} ${args} > "$OUT" 200<&- 2>&1 < /dev/null &
+ else
+ java ${JAVA_OPTS} -cp ${CLASS_PATH} ${APP_MAIN} ${args}
+fi
+
diff --git a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/args/ServerCommandArgs.java b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/args/ServerCommandArgs.java
index 35e8e3e87..8cf9e41a4 100644
--- a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/args/ServerCommandArgs.java
+++ b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/args/ServerCommandArgs.java
@@ -33,6 +33,11 @@ public class ServerCommandArgs extends CommandArgs {
             description = "The name of cluster")
     private String clusterName;
 
+    @Parameter(
+            names = {"-d", "--daemon"},
+            description = "The cluster daemon mode")
+    private boolean daemonMode = false;
+
     @Override
     public Command<?> buildCommand() {
         return new ServerExecuteCommand(this);