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 ed90ddd8461..d40fd6afbdb 100755 --- a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.sh +++ b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-cluster.sh @@ -34,13 +34,15 @@ while [ -h "$PRG" ] ; do done PRG_DIR=`dirname "$PRG"` -APP_DIR=`cd "$PRG_DIR/.." >/dev/null; pwd` -CONF_DIR=${APP_DIR}/config -APP_JAR=${APP_DIR}/starter/seatunnel-starter.jar +APP_DIR_DEFAULT=`cd "$PRG_DIR/.." >/dev/null; pwd` +APP_DIR=${APP_DIR:-"${APP_DIR_DEFAULT}"} +CONF_DIR=${CONF_DIR:-${APP_DIR}/config} +LOG_DIR=${LOG_DIR:-${APP_DIR}/logs} +MASTER_OUT="${LOG_DIR}/seatunnel-engine-master.out" +WORKER_OUT="${LOG_DIR}/seatunnel-engine-worker.out" +OUT="${LOG_DIR}/seatunnel-server.out" +APP_JAR="${APP_DIR}/starter/seatunnel-starter.jar" APP_MAIN="org.apache.seatunnel.core.starter.seatunnel.SeaTunnelServer" -MASTER_OUT="${APP_DIR}/logs/seatunnel-engine-master.out" -WORKER_OUT="${APP_DIR}/logs/seatunnel-engine-worker.out" -OUT="${APP_DIR}/logs/seatunnel-server.out" HELP=false NODE_ROLE="master_and_worker" @@ -86,7 +88,7 @@ JAVA_OPTS="${JAVA_OPTS} -Dlog4j2.contextSelector=org.apache.logging.log4j.core.a JAVA_OPTS="${JAVA_OPTS} -Dlog4j2.isThreadContextMapInheritable=true -DAsyncLogger.ThreadNameStrategy=UNCACHED" if [ -e "${CONF_DIR}/log4j2.properties" ]; then JAVA_OPTS="${JAVA_OPTS} -Dhazelcast.logging.type=log4j2 -Dlog4j2.configurationFile=${CONF_DIR}/log4j2.properties" - JAVA_OPTS="${JAVA_OPTS} -Dseatunnel.logs.path=${APP_DIR}/logs" + JAVA_OPTS="${JAVA_OPTS} -Dseatunnel.logs.path=${LOG_DIR}" fi if [ "$NODE_ROLE" = "master" ]; then @@ -96,7 +98,7 @@ if [ "$NODE_ROLE" = "master" ]; then if [[ ! "$line" =~ ^# ]]; then JAVA_OPTS="$JAVA_OPTS $line" fi - done < ${APP_DIR}/config/jvm_master_options + done < "${CONF_DIR}"/jvm_master_options # SeaTunnel Engine Config if [ -z $HAZELCAST_CONFIG ]; then HAZELCAST_CONFIG=${CONF_DIR}/hazelcast-master.yaml @@ -118,7 +120,7 @@ elif [ "$NODE_ROLE" = "master_and_worker" ]; then if [[ ! "$line" =~ ^# ]]; then JAVA_OPTS="$JAVA_OPTS $line" fi - done < ${APP_DIR}/config/jvm_options + done < "${CONF_DIR}"/jvm_options if [ -z $HAZELCAST_CONFIG ]; then HAZELCAST_CONFIG=${CONF_DIR}/hazelcast.yaml fi @@ -153,8 +155,8 @@ CLASS_PATH=${APP_DIR}/lib/*:${APP_JAR} echo "start ${NODE_ROLE} node" if [[ $DAEMON == true && $HELP == false ]]; then - if [[ ! -d ${APP_DIR}/logs ]]; then - mkdir -p ${APP_DIR}/logs + if [[ ! -d "${LOG_DIR}" ]]; then + mkdir -p "${LOG_DIR}" fi touch $OUT nohup java ${JAVA_OPTS} -cp ${CLASS_PATH} ${APP_MAIN} ${args} > "$OUT" 200<&- 2>&1 < /dev/null & diff --git a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-connector.sh b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-connector.sh index 92dfa3d275e..e629c060bf0 100755 --- a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-connector.sh +++ b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel-connector.sh @@ -17,6 +17,10 @@ # set -eu +if [ -f "/etc/seatunnel/conf/seatunnel-env.sh" ]; then + . "/etc/seatunnel/conf/seatunnel-env.sh" + echo "Using /etc/seatunnel/conf/seatunnel-env.sh." +fi # resolve links - $0 may be a softlink PRG="$0" @@ -34,7 +38,8 @@ while [ -h "$PRG" ] ; do done PRG_DIR=$(dirname "$PRG") -APP_DIR=$(cd "$PRG_DIR/.." >/dev/null; pwd) +APP_DIR_DEFAULT=$(cd "$PRG_DIR/.." >/dev/null; pwd) +APP_DIR=${APP_DIR:-$APP_DIR_DEFAULT} APP_JAR=${APP_DIR}/starter/seatunnel-starter.jar LOAD_CLASS="org.apache.seatunnel.core.starter.seatunnel.SeaTunnelConnector" diff --git a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh index 754f2337c62..4e2126b504e 100755 --- a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh +++ b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh @@ -17,6 +17,12 @@ # set -eu + +if [ -f "/etc/seatunnel/conf/seatunnel-env.sh" ]; then + . "/etc/seatunnel/conf/seatunnel-env.sh" + echo "Using /etc/seatunnel/conf/seatunnel-env.sh." +fi + # resolve links - $0 may be a softlink PRG="$0" @@ -34,9 +40,11 @@ while [ -h "$PRG" ] ; do done PRG_DIR=`dirname "$PRG"` -APP_DIR=`cd "$PRG_DIR/.." >/dev/null; pwd` -SEATUNNEL_HOME=${APP_DIR} -CONF_DIR=${APP_DIR}/config +APP_DIR_DEFAULT=`cd "$PRG_DIR/.." >/dev/null; pwd` +APP_DIR=${APP_DIR:-$APP_DIR_DEFAULT} +LOG_DIR=${LOG_DIR:-${APP_DIR}/logs} +CONF_DIR=${CONF_DIR:-${APP_DIR}/config} + APP_JAR=${APP_DIR}/starter/seatunnel-starter.jar APP_MAIN="org.apache.seatunnel.core.starter.seatunnel.SeaTunnelClient" @@ -83,7 +91,7 @@ JAVA_OPTS="${JAVA_OPTS} -Dhazelcast.config=${HAZELCAST_CONFIG}" JAVA_OPTS="${JAVA_OPTS} -Dlog4j2.isThreadContextMapInheritable=true" if [ -e "${CONF_DIR}/log4j2_client.properties" ]; then JAVA_OPTS="${JAVA_OPTS} -Dhazelcast.logging.type=log4j2 -Dlog4j2.configurationFile=${CONF_DIR}/log4j2_client.properties" - JAVA_OPTS="${JAVA_OPTS} -Dseatunnel.logs.path=${APP_DIR}/logs" + JAVA_OPTS="${JAVA_OPTS} -Dseatunnel.logs.path=${LOG_DIR}" if [[ $args == *" -m local"* || $args == *" --master local"* || $args == *" -e local"* || $args == *" --deploy-mode local"* ]]; then ntime=$(echo `date "+%N"`|sed -r 's/^0+//') JAVA_OPTS="${JAVA_OPTS} -Dseatunnel.logs.file_name=seatunnel-starter-client-$((`date '+%s'`*1000+$ntime/1000000))" @@ -98,7 +106,7 @@ while IFS= read -r line || [[ -n "$line" ]]; do if [[ ! $line == \#* ]]; then JAVA_OPTS="$JAVA_OPTS $line" fi -done < ${APP_DIR}/config/jvm_client_options +done < "${CONF_DIR}"/jvm_client_options # Parse JvmOption from command line, it should be parsed after jvm_client_options for i in "$@" diff --git a/seatunnel-dist/pom.xml b/seatunnel-dist/pom.xml index d635d2ea4eb..4932b60623a 100644 --- a/seatunnel-dist/pom.xml +++ b/seatunnel-dist/pom.xml @@ -32,6 +32,11 @@ true + true + 1 + ${project.version}-${rpm.release.number} + /usr/bigtop + ${project.version}-${rpm.release.number} @@ -68,6 +73,112 @@ + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + + + postinstall_script + + run + + generate-resources + + + #!/bin/sh + mkdir -p ${rpm.stack.root}/current + ln -sfn ${rpm.stack.root}/${rpm.version}/seatunnel ${rpm.stack.root}/current + chmod 755 ${rpm.stack.root}/${rpm.version}/seatunnel/bin/*.sh + chmod 755 /etc/seatunnel/conf/*.sh + + + + + postremove_script + + run + + generate-resources + + + #!/bin/sh + rm -rf ${rpm.stack.root}/current/seatunnel + rm -rf ${rpm.stack.root}/${rpm.version} + + + + + + + org.codehaus.mojo + rpm-maven-plugin + 2.3.0 + + + generate-rpm + + rpm + + package + + Development + seatunnel + ${project.version} + ${rpm.release.number} + x86_64 + Application/Java + 644 + 755 + root + root + false + ${rpm.build.disable} + + + ${rpm.stack.root}/${rpm.version}/seatunnel/ + + + ${project.build.directory}/apache-seatunnel-${project.version}-bin/apache-seatunnel-${project.version}/ + + config/** + + + + + + /etc/seatunnel/conf/ + + + ${project.build.directory}/apache-seatunnel-${project.version}-bin/apache-seatunnel-${project.version}/config/ + + + + + /usr/sbin + 755 + root + root + false + + + ${project.basedir}/sbin/seatunnel + + + + + + ${project.build.directory}/postinstall.sh + utf-8 + + + ${project.build.directory}/postremove.sh + utf-8 + + + + + diff --git a/seatunnel-dist/sbin/seatunnel b/seatunnel-dist/sbin/seatunnel new file mode 100755 index 00000000000..d7ac9eb2c8e --- /dev/null +++ b/seatunnel-dist/sbin/seatunnel @@ -0,0 +1,58 @@ +#!/bin/sh +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +set - + +if [ -f "/etc/seatunnel/conf/seatunnel-env.sh" ]; then + . "/etc/seatunnel/conf/seatunnel-env.sh" + echo "Using /etc/seatunnel/conf/seatunnel-env.sh." +else + echo "File /etc/seatunnel/conf/seatunnel-env.sh does not exist." + exit 1 +fi +if [ -z "${APP_DIR}" ]; then + echo "APP_DIR is not set. It must be set in seatunnel-env.sh" + exit 1 +fi +BIN_DIR="${APP_DIR}/bin" + +start() { + echo "starting seatunnel" + . "${BIN_DIR}/seatunnel-cluster.sh" -d + echo "seatunnel started" +} + +stop() { + echo "stopping seatunnel..." + . "${BIN_DIR}/stop-seatunnel-cluster.sh" + echo "seatunnel stopped" +} + +status() { + if jcmd | grep -q -i 'org.apache.seatunnel.core.starter.seatunnel.SeaTunnelServer'; then + echo "seatunnel is running" + else + echo "seatunnel is not running" + fi +} + +case "$1" in + "start") start ;; + "stop") stop ;; + "status") status ;; + *) echo "Usage: seatunnel {start|stop|status}"; exit 1 ;; +esac \ No newline at end of file diff --git a/seatunnel-dist/src/main/assembly/assembly-bin-ci.xml b/seatunnel-dist/src/main/assembly/assembly-bin-ci.xml index 2ed7f180b7b..f387a7e7cd4 100644 --- a/seatunnel-dist/src/main/assembly/assembly-bin-ci.xml +++ b/seatunnel-dist/src/main/assembly/assembly-bin-ci.xml @@ -21,6 +21,7 @@ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd"> bin + dir tar.gz true