This is an automated email from the ASF dual-hosted git repository.
dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git
The following commit(s) were added to refs/heads/master by this push:
new a02d445ced [INLONG-8942][Distribution] Support merging multiple module
jars to reduce distribution package size (#8943)
a02d445ced is described below
commit a02d445ced1ee7a4e48ae3cb3b37c65a809e9530
Author: 卢春亮 <[email protected]>
AuthorDate: Thu Sep 21 10:42:39 2023 +0800
[INLONG-8942][Distribution] Support merging multiple module jars to reduce
distribution package size (#8943)
---
inlong-agent/bin/agent.sh | 6 ++
inlong-audit/bin/proxy-start.sh | 6 ++
inlong-audit/bin/store-start.sh | 6 ++
inlong-dataproxy/bin/dataproxy-start.sh | 6 ++
inlong-distribution/pom.xml | 18 +++++-
.../script/backup_module_dependencys.sh | 74 ++++++++++++++++++++++
.../script/copy_module_dependencys.sh | 36 +++++++++++
.../script/prepare_module_dependencys.sh | 31 +++++++++
inlong-manager/manager-web/bin/startup.sh | 6 ++
inlong-tubemq/bin/env.sh | 6 ++
inlong-tubemq/tubemq-manager/bin/start-manager.sh | 6 ++
11 files changed, 200 insertions(+), 1 deletion(-)
diff --git a/inlong-agent/bin/agent.sh b/inlong-agent/bin/agent.sh
index 60f827af69..480b55a219 100755
--- a/inlong-agent/bin/agent.sh
+++ b/inlong-agent/bin/agent.sh
@@ -18,6 +18,12 @@
BASE_DIR=$(dirname $0)/..
+# Prepare common dependency
+ROOT_DIR=$BASE_DIR/..
+if [ -e $ROOT_DIR/bin/prepare_module_dependencys.sh ]; then
+ $ROOT_DIR/bin/prepare_module_dependencys.sh ./inlong-agent/lib
+fi
+
source "${BASE_DIR}"/bin/agent-env.sh
CONSOLE_OUTPUT_FILE="${LOG_DIR}/agent-out.log"
diff --git a/inlong-audit/bin/proxy-start.sh b/inlong-audit/bin/proxy-start.sh
index 47460ea9aa..0bd6e25879 100644
--- a/inlong-audit/bin/proxy-start.sh
+++ b/inlong-audit/bin/proxy-start.sh
@@ -30,6 +30,12 @@ BASE_DIR=$(
# shellcheck disable=SC2164
cd "$BASE_DIR"
+# Prepare common dependency
+ROOT_DIR=$BASE_DIR/..
+if [ -e $ROOT_DIR/bin/prepare_module_dependencys.sh ]; then
+ $ROOT_DIR/bin/prepare_module_dependencys.sh ./inlong-audit/lib
+fi
+
error() {
local msg=$1
local exit_code=$2
diff --git a/inlong-audit/bin/store-start.sh b/inlong-audit/bin/store-start.sh
index 2b048e5602..002b7c0f7e 100644
--- a/inlong-audit/bin/store-start.sh
+++ b/inlong-audit/bin/store-start.sh
@@ -31,6 +31,12 @@ BASE_DIR=$(dirname $SCRIPT_DIR)
cd "$BASE_DIR"
cd ../
+# Prepare common dependency
+ROOT_DIR=$BASE_DIR/../..
+if [ -e $ROOT_DIR/bin/prepare_module_dependencys.sh ]; then
+ $ROOT_DIR/bin/prepare_module_dependencys.sh ./inlong-audit/lib
+fi
+
PID=$(ps -ef | grep "audit-store" | grep -v grep | awk '{ print $2}')
LOG_DIR="${BASE_DIR}/logs"
diff --git a/inlong-dataproxy/bin/dataproxy-start.sh
b/inlong-dataproxy/bin/dataproxy-start.sh
index c16aff658c..a7aa2df133 100755
--- a/inlong-dataproxy/bin/dataproxy-start.sh
+++ b/inlong-dataproxy/bin/dataproxy-start.sh
@@ -21,6 +21,12 @@
cd "$(dirname "$0")"/../conf || exit
basedir="$(pwd)"
+# Prepare common dependency
+ROOT_DIR=$basedir/../..
+if [ -e $ROOT_DIR/bin/prepare_module_dependencys.sh ]; then
+ $ROOT_DIR/bin/prepare_module_dependencys.sh ./inlong-dataproxy/lib
+fi
+
error() {
local msg=$1
local exit_code=$2
diff --git a/inlong-distribution/pom.xml b/inlong-distribution/pom.xml
index aa050d0ea4..03224d0e06 100644
--- a/inlong-distribution/pom.xml
+++ b/inlong-distribution/pom.xml
@@ -70,7 +70,23 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>3.1.0</version>
+ <configuration>
+
<executable>${basedir}/script/backup_module_dependencys.sh</executable>
+ </configuration>
+ <executions>
+ <execution>
+ <id>uncompress</id>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <phase>install</phase>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
-
</project>
diff --git a/inlong-distribution/script/backup_module_dependencys.sh
b/inlong-distribution/script/backup_module_dependencys.sh
new file mode 100755
index 0000000000..909def54b2
--- /dev/null
+++ b/inlong-distribution/script/backup_module_dependencys.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+#
+#
+# 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.
+#
+cd "$(dirname "$0")"/../ || exit
+
+filelist() {
+ rm -fr $1/dependencys.txt
+ for file in $1/*
+ do
+ if [[ -f $file ]]; then
+ if [[ $file == *".jar" ]]; then
+ filename=$(basename "$file")
+ echo $filename >> $1/dependencys.txt
+ fi
+ fi
+ done
+}
+
+# Get the current version for InLong
+find_gz_file=`ls -l ./target/*bin.tar.gz |awk '{print $9}'`
+gz_file=$(basename "$find_gz_file")
+name_length=`expr length $gz_file`
+version_length=$(expr $name_length \- 15 \- 10)
+project_version=`expr substr $gz_file 15 $version_length`
+projectpath="./target/apache-inlong-${project_version}-bin/apache-inlong-${project_version}"
+
+# Generate the file "dependencys.txt"
+filelist "./$projectpath/inlong-agent/lib"
+filelist "./$projectpath/inlong-dataproxy/lib"
+filelist "./$projectpath/inlong-manager/lib"
+filelist "./$projectpath/inlong-tubemq-server/lib"
+filelist "./$projectpath/inlong-tubemq-manager/lib"
+filelist "./$projectpath/inlong-audit/lib"
+
+# Move every module jar file to same lib directory
+mkdir -p $projectpath/lib
+mv $projectpath/inlong-agent/lib/*.jar $projectpath/lib/
+mv $projectpath/inlong-dataproxy/lib/*.jar $projectpath/lib/
+mv $projectpath/inlong-manager/lib/*.jar $projectpath/lib/
+mv $projectpath/inlong-tubemq-server/lib/*.jar $projectpath/lib/
+mv $projectpath/inlong-tubemq-manager/lib/*.jar $projectpath/lib/
+mv $projectpath/inlong-audit/lib/*.jar $projectpath/lib/
+
+# Copy the file "copy_module_dependencys.sh" to bin directory
+cp ./script/copy_module_dependencys.sh $projectpath/bin/
+chmod 755 $projectpath/bin/copy_module_dependencys.sh
+
+# Copy the file "prepare_module_dependencys.sh" to bin directory
+cp ./script/prepare_module_dependencys.sh $projectpath/bin/
+chmod 755 $projectpath/bin/prepare_module_dependencys.sh
+
+# Package InLong version file
+lastname=$(basename "$projectpath")
+cd $projectpath/..
+tar cvf $lastname-bin.tar $lastname
+gzip $lastname-bin.tar
+mv $lastname-bin.tar.gz ../
diff --git a/inlong-distribution/script/copy_module_dependencys.sh
b/inlong-distribution/script/copy_module_dependencys.sh
new file mode 100755
index 0000000000..a6b2abae27
--- /dev/null
+++ b/inlong-distribution/script/copy_module_dependencys.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+#
+# 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.
+#
+cd "$(dirname "$0")"/../ || exit
+
+copyfile() {
+ for line in $(cat "$1/dependencys.txt"); do
+ cp "./lib/$line" $1/
+ done
+}
+
+# Copy the jar files in dependencys.txt to every module directory
+copyfile "./inlong-agent/lib"
+copyfile "./inlong-dataproxy/lib"
+copyfile "./inlong-manager/lib"
+copyfile "./inlong-tubemq-server/lib"
+copyfile "./inlong-tubemq-manager/lib"
+copyfile "./inlong-audit/lib"
+rm -fr ./lib
diff --git a/inlong-distribution/script/prepare_module_dependencys.sh
b/inlong-distribution/script/prepare_module_dependencys.sh
new file mode 100755
index 0000000000..13a73cf6e1
--- /dev/null
+++ b/inlong-distribution/script/prepare_module_dependencys.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+#
+# 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.
+#
+cd "$(dirname "$0")"/../ || exit
+
+jar_file_num=`ls -l $1 |grep jar |wc -l`
+
+if [ $jar_file_num -eq 0 ]; then
+ if [ -e $1/dependencys.txt ]; then
+ for line in $(cat "$1/dependencys.txt"); do
+ cp "./lib/$line" $1/
+ done
+ fi
+fi
diff --git a/inlong-manager/manager-web/bin/startup.sh
b/inlong-manager/manager-web/bin/startup.sh
index 8b4651f0e9..2204077a11 100755
--- a/inlong-manager/manager-web/bin/startup.sh
+++ b/inlong-manager/manager-web/bin/startup.sh
@@ -43,6 +43,12 @@ BIN_PATH=$(
pwd
)
+# Prepare common dependency
+ROOT_DIR=$BIN_PATH/../..
+if [ -e $ROOT_DIR/bin/prepare_module_dependencys.sh ]; then
+ $ROOT_DIR/bin/prepare_module_dependencys.sh ./inlong-manager/lib
+fi
+
# Enter the root directory path
# shellcheck disable=SC2164
cd "$BIN_PATH"
diff --git a/inlong-tubemq/bin/env.sh b/inlong-tubemq/bin/env.sh
index aabac44f80..cf0590bf5c 100755
--- a/inlong-tubemq/bin/env.sh
+++ b/inlong-tubemq/bin/env.sh
@@ -26,6 +26,12 @@ else
export JAVA="$JAVA_HOME/bin/java"
fi
+# Prepare common dependency
+ROOT_DIR=$BASE_DIR/..
+if [ -e $ROOT_DIR/bin/prepare_module_dependencys.sh ]; then
+ $ROOT_DIR/bin/prepare_module_dependencys.sh ./inlong-tubemq-server/lib
+fi
+
tubemq_home=$BASE_DIR
export CLASSPATH=$CLASSPATH:$BASE_DIR/conf:$(ls $BASE_DIR/lib/*.jar | tr '\n'
:)
diff --git a/inlong-tubemq/tubemq-manager/bin/start-manager.sh
b/inlong-tubemq/tubemq-manager/bin/start-manager.sh
index e48ed46679..9157face6d 100644
--- a/inlong-tubemq/tubemq-manager/bin/start-manager.sh
+++ b/inlong-tubemq/tubemq-manager/bin/start-manager.sh
@@ -18,6 +18,12 @@
base_dir=$(dirname $0)
+# Prepare common dependency
+ROOT_DIR=$base_dir/../..
+if [ -e $ROOT_DIR/bin/prepare_module_dependencys.sh ]; then
+ $ROOT_DIR/bin/prepare_module_dependencys.sh ./inlong-tubemq-manager/lib
+fi
+
DAEMON_NAME=${DAEMON_NAME:-"tubemq-manager"}
LOG_DIR=${LOG_DIR:-"$base_dir/../logs"}
CONF_DIR=${CONF_DIR:-"$base_dir/../conf"}