From 2e6dc1c4dd6931e711057d242fc2d39bff27b094 Mon Sep 17 00:00:00 2001 From: Mohammad Arshad Date: Thu, 10 Apr 2025 17:43:19 +0530 Subject: [PATCH] [Feature] Add Support for RPM Generation Enable RPM generation by passing the flag -Drpm.build.disable=false --- .../src/main/bin/seatunnel-backend-daemon.sh | 21 ++- seatunnel-web-dist/conf/seatunnel-web-env.sh | 37 ++++++ seatunnel-web-dist/pom.xml | 122 ++++++++++++++++++ seatunnel-web-dist/sbin/seatunnel-web | 72 +++++++++++ 4 files changed, 245 insertions(+), 7 deletions(-) create mode 100755 seatunnel-web-dist/conf/seatunnel-web-env.sh create mode 100755 seatunnel-web-dist/sbin/seatunnel-web diff --git a/seatunnel-server/seatunnel-app/src/main/bin/seatunnel-backend-daemon.sh b/seatunnel-server/seatunnel-app/src/main/bin/seatunnel-backend-daemon.sh index 582fcb461..73780116a 100755 --- a/seatunnel-server/seatunnel-app/src/main/bin/seatunnel-backend-daemon.sh +++ b/seatunnel-server/seatunnel-app/src/main/bin/seatunnel-backend-daemon.sh @@ -21,6 +21,9 @@ set - # usage: seatunnel-backend-daemon.sh WORKDIR=$(cd "$(dirname "$0")" || exit; pwd) +SEATUNNEL_WEB_HOME=${SEATUNNEL_WEB_HOME:-"$WORKDIR/.."} +LOGDIR=${LOGDIR:-"${SEATUNNEL_WEB_HOME}/logs"} +CONFDIR=${CONFDIR:-"${SEATUNNEL_WEB_HOME}/conf"} # check check() { @@ -39,12 +42,16 @@ start() { check - LOGDIR=${WORKDIR}/../logs # Create the log directory if it does not exist if [ ! -d "$LOGDIR" ]; then mkdir -p "$LOGDIR" fi - JAVA_OPTS="${JAVA_OPTS} -server -Xms1g -Xmx1g -Xmn512m -XX:+PrintGCDetails -Xloggc:${LOGDIR}/gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof" + + JAVA_MEMORY_OPTS=${JAVA_MEMORY_OPTS:-"-Xms1g -Xmx1g -Xmn512m"} + JAVA_GC_OPTS=${JAVA_GC_OPTS:-"-XX:+PrintGCDetails -Xloggc:${LOGDIR}/gc.log"} + JAVA_ERROR_OPTS=${JAVA_ERROR_OPTS:-"-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOGDIR}/dump.hprof"} + + JAVA_OPTS="${JAVA_OPTS} -server $JAVA_MEMORY_OPTS $JAVA_GC_OPTS $JAVA_ERROR_OPTS" SPRING_OPTS="${SPRING_OPTS} -Dspring.config.name=application.yml -Dspring.config.location=classpath:application.yml" JAVA_OPTS="${JAVA_OPTS} -Dseatunnel-web.logs.path=${LOGDIR}" # check env JAVA_HOME @@ -53,11 +60,11 @@ start() { exit 1 fi - echo "$WORKDIR" - CLASSPATH="$WORKDIR/../conf:$WORKDIR/../libs/*:$WORKDIR/../datasource/*" - if [ -d "$WORKDIR/../ranger-seatunnel-plugin" ]; then - CLASSPATH="$CLASSPATH:$WORKDIR/../ranger-seatunnel-plugin/lib/*.jar" - CLASSPATH="$CLASSPATH:$WORKDIR/../ranger-seatunnel-plugin/lib/ranger-seatunnel-plugin-impl/*" + echo "$SEATUNNEL_WEB_HOME" + CLASSPATH="$CONFDIR:$SEATUNNEL_WEB_HOME/libs/*:$SEATUNNEL_WEB_HOME/datasource/*" + if [ -d "$SEATUNNEL_WEB_HOME/ranger-seatunnel-plugin" ]; then + CLASSPATH="$CLASSPATH:$SEATUNNEL_WEB_HOME/ranger-seatunnel-plugin/lib/*.jar" + CLASSPATH="$CLASSPATH:$SEATUNNEL_WEB_HOME/ranger-seatunnel-plugin/lib/ranger-seatunnel-plugin-impl/*" fi nohup $JAVA_HOME/bin/java $JAVA_OPTS \ diff --git a/seatunnel-web-dist/conf/seatunnel-web-env.sh b/seatunnel-web-dist/conf/seatunnel-web-env.sh new file mode 100755 index 000000000..4e5795bf8 --- /dev/null +++ b/seatunnel-web-dist/conf/seatunnel-web-env.sh @@ -0,0 +1,37 @@ +#!/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. +# + +# Default directories +STACK_ROOT=${STACK_ROOT:-"/usr/bigtop"} +export LOGDIR=${LOGDIR:-"/var/log/seatunnel-web"} +export CONFDIR=${CONFDIR:-"/etc/seatunnel-web/conf"} +export SEATUNNEL_WEB_HOME=${SEATUNNEL_WEB_HOME:-"$STACK_ROOT/current/seatunnel-web"} +export SEATUNNEL_HOME="${STACK_ROOT}/current/seatunnel" + +# JVM options +export JAVA_MEMORY_OPTS=${JAVA_MEMORY_OPTS:-"-Xms2g -Xmx4g -Xmn1g"} +export JAVA_GC_OPTS=${JAVA_GC_OPTS:-"-XX:+PrintGCDetails -Xloggc:${LOGDIR}/gc.log"} +export JAVA_ERROR_OPTS=${JAVA_ERROR_OPTS:-"-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOGDIR}/dump.hprof"} + +#JDK17_OPTS="--add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.security.jgss/sun.security.krb5=ALL-UNNAMED" +#JAVA_OPTS="$JAVA_OPTS $JDK17_OPTS" + +#DEBUG_OPTS="-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=*:8476,suspend=n" +#DEBUG_OPTS="$DEBUG_OPTS -verbose:class" +#export JAVA_OPTS="$JAVA_OPTS $DEBUG_OPTS" + diff --git a/seatunnel-web-dist/pom.xml b/seatunnel-web-dist/pom.xml index 531e31f0d..0765ca03b 100644 --- a/seatunnel-web-dist/pom.xml +++ b/seatunnel-web-dist/pom.xml @@ -36,6 +36,10 @@ 42.4.3 9.2.1.jre8 8.0.28 + true + 1 + /usr/bigtop + ${project.version}-${rpm.release.number} @@ -481,6 +485,124 @@ + + 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-web ${rpm.stack.root}/current + chmod 755 ${rpm.stack.root}/${rpm.version}/seatunnel-web/bin/*.sh + chmod 755 /etc/seatunnel-web/conf/*.sh + + + + + postremove_script + + run + + generate-resources + + + #!/bin/sh + rm -f ${rpm.stack.root}/current/seatunnel-web + rm -rf ${rpm.stack.root}/${rpm.version} + + + + + + + org.codehaus.mojo + rpm-maven-plugin + 2.3.0 + + + generate-rpm + + rpm + + package + + Development + seatunnel-web + ${project.version} + ${rpm.release.number} + x86_64 + Application/Java + 644 + 755 + root + root + false + ${rpm.build.disable} + + + ${rpm.stack.root}/${rpm.version}/seatunnel-web/ + + + ${project.build.directory}/apache-seatunnel-web-${project.version}/apache-seatunnel-web-${project.version}/ + + conf/** + + + + + + /etc/seatunnel-web/ + + + ${project.build.directory}/apache-seatunnel-web-${project.version}/apache-seatunnel-web-${project.version}/ + + conf/** + + + + + + /usr/sbin + 755 + root + root + false + + + ${project.basedir}/sbin/seatunnel-web + + + + + /etc/seatunnel-web/conf/ + 755 + + + ${project.basedir}/conf/seatunnel-web-env.sh + + + + + + ${project.build.directory}/postinstall.sh + utf-8 + + + ${project.build.directory}/postremove.sh + utf-8 + + + + + diff --git a/seatunnel-web-dist/sbin/seatunnel-web b/seatunnel-web-dist/sbin/seatunnel-web new file mode 100755 index 000000000..a6c133850 --- /dev/null +++ b/seatunnel-web-dist/sbin/seatunnel-web @@ -0,0 +1,72 @@ +#!/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 - +# Usage: seatunnel-web {start|stop|status} +CONFDIR=${CONFDIR:-"/etc/seatunnel-web/conf"} + +# Load environment variables if the configuration file exists +if [ -f "${CONFDIR}/seatunnel-web-env.sh" ]; then + . "${CONFDIR}/seatunnel-web-env.sh" +else + echo "Error: ${CONFDIR}/seatunnel-web-env.sh not found." + exit 1 +fi +if [ -z "${SEATUNNEL_WEB_HOME}" ]; then + echo "Error: SEATUNNEL_WEB_HOME is not set. It must be set in seatunnel-web-env.sh" + exit 1 +fi + +if [ -z "${SEATUNNEL_HOME}" ]; then + echo "Error: SEATUNNEL_HOME is not set. It must be set in seatunnel-web-env.sh" + exit 1 +fi + +# start +start() { + cd "${SEATUNNEL_WEB_HOME}" || exit + sh ./bin/seatunnel-backend-daemon.sh start +} +# Stop the Seatunnel application +stop() { + cd "${SEATUNNEL_WEB_HOME}" || exit + sh ./bin/seatunnel-backend-daemon.sh stop +} + +# Check the status of the Seatunnel application +status() { + cd "${SEATUNNEL_WEB_HOME}" || exit + sh ./bin/seatunnel-backend-daemon.sh status +} + +# main +case "$1" in +"start") + start + ;; +"stop") + stop + ;; +"status") + status + ;; +*) + echo "Usage: seatunnel-web {start|stop|status}" + exit 1 +esac