Skip to content

Commit

Permalink
[Improve][Seatunnel-Cluster] Run the server through daemon (apache#4161)
Browse files Browse the repository at this point in the history
* Add Support SeaTunnel Zeta Cluster Node Run Through A Daemon
  • Loading branch information
liugddx authored and hailin0 committed Mar 23, 2023
1 parent 36586c9 commit e809d87
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
4 changes: 3 additions & 1 deletion docs/en/seatunnel-engine/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
1 change: 1 addition & 0 deletions release-note.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand All @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e809d87

Please sign in to comment.