Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve]Add external lib folder to store mysql and oracle driver. #1783

Merged
merged 11 commits into from
Apr 21, 2024
Merged
1 change: 0 additions & 1 deletion manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
<maven.install.skip>true</maven.install.skip>
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
<maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
<mysql.version>8.0.28</mysql.version>
<nekohtml.version>1.9.22</nekohtml.version>
<spring-boot-starter-sureness.version>1.1.0</spring-boot-starter-sureness.version>
<warehouse.version>1.0</warehouse.version>
Expand Down
2 changes: 1 addition & 1 deletion manager/src/main/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spring:
driver-class-name: org.h2.Driver
username: sa
password: 123456
url: jdbc:h2:./data/hertzbeat-test;MODE=MYSQL
url: jdbc:h2:./data/test;MODE=MYSQL
hikari:
max-lifetime: 120000
jpa:
Expand Down
9 changes: 9 additions & 0 deletions script/assembly/collector/assembly-linux-amd64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,14 @@ http://maven.apache.org/ASSEMBLY/2.0.0 ">
<directory>../jdk/linux-amd64</directory>
<outputDirectory>java</outputDirectory>
</fileSet>

<!-- external lib -->
<fileSet>
<directory>../script/ext-lib</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>ext-lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
9 changes: 9 additions & 0 deletions script/assembly/collector/assembly-linux-arm64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,14 @@ http://maven.apache.org/ASSEMBLY/2.0.0 ">
<directory>../jdk/linux-arm64</directory>
<outputDirectory>java</outputDirectory>
</fileSet>

<!-- external lib -->
<fileSet>
<directory>../script/ext-lib</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>ext-lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
9 changes: 9 additions & 0 deletions script/assembly/collector/assembly-macos-amd64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,14 @@ http://maven.apache.org/ASSEMBLY/2.0.0 ">
<directory>../jdk/macos-amd64</directory>
<outputDirectory>java</outputDirectory>
</fileSet>

<!-- external lib -->
<fileSet>
<directory>../script/ext-lib</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>ext-lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
9 changes: 9 additions & 0 deletions script/assembly/collector/assembly-macos-arm64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,14 @@ http://maven.apache.org/ASSEMBLY/2.0.0 ">
<directory>../jdk/macos-arm64</directory>
<outputDirectory>java</outputDirectory>
</fileSet>

<!-- external lib -->
<fileSet>
<directory>../script/ext-lib</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>ext-lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
9 changes: 9 additions & 0 deletions script/assembly/collector/assembly-windows-64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,14 @@ http://maven.apache.org/ASSEMBLY/2.0.0 ">
<directory>../jdk/windows-64</directory>
<outputDirectory>java</outputDirectory>
</fileSet>

<!-- external lib -->
<fileSet>
<directory>../script/ext-lib</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>ext-lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
10 changes: 9 additions & 1 deletion script/assembly/collector/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ http://maven.apache.org/ASSEMBLY/2.0.0 ">
<include>*.jar</include>
</includes>
</fileSet>


<!-- external lib -->
<fileSet>
<directory>../script/ext-lib</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>ext-lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
6 changes: 4 additions & 2 deletions script/assembly/collector/bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ DEPLOY_DIR=`pwd`
# 外部配置文件绝对目录,如果是目录需要/结尾,也可以直接指定文件
# 如果指定的是目录,spring则会读取目录中的所有配置文件
CONF_DIR=$DEPLOY_DIR/config

MAIN_CLASS="org.apache.hertzbeat.collector.Collector"
EXT_LIB_PATH="$DEPLOY_DIR/ext-lib"
CLASSPATH="$DEPLOY_DIR/$JAR_NAME:$EXT_LIB_PATH/*"
# 项目日志输出绝对路径
LOGS_DIR=$DEPLOY_DIR/logs
# 如果logs文件夹不存在,则创建文件夹
Expand All @@ -58,4 +60,4 @@ then
fi
CONFIG_FILES=" -Dlogging.path=$LOGS_DIR $LOGGING_CONFIG -Dspring.config.location=$CONF_DIR/ "
echo -e "Starting the HertzBeat $SERVER_NAME ..."
java $JAVA_OPTS $JAVA_MEM_OPTS $CONFIG_FILES -jar $DEPLOY_DIR/$JAR_NAME --spring.profiles.active=cluster
java $JAVA_OPTS $JAVA_MEM_OPTS $CONFIG_FILES -cp $CLASSPATH $MAIN_CLASS --spring.profiles.active=cluster
8 changes: 5 additions & 3 deletions script/assembly/collector/bin/startup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ for /f "tokens=1-5" %%i in ('netstat -ano^|findstr "0.0.0.0:%SERVER_PORT%"') do
echo exit!
goto q
)

set MAIN_CLASS=org.apache.hertzbeat.collector.Collector
set LOGS_DIR=%DEPLOY_DIR%\logs
set EXT_LIB_PATH=%DEPLOY_DIR%\ext-lib
set CLASSPATH=%DEPLOY_DIR%\%JAR_NAME%;%EXT_LIB_PATH%\*

if not exist %LOGS_DIR% (
mkdir %LOGS_DIR%
Expand All @@ -64,12 +66,12 @@ set INNER_EXE=%DEPLOY_DIR%\java\bin\javaw.exe
if not exist %INNER_EXE% (
echo "Use the system environment jdk to start"

start javaw %JAVA_OPTS% %JAVA_MEM_OPTS% %CONFIG_FILES% -jar %DEPLOY_DIR%\%JAR_NAME%
start javaw %JAVA_OPTS% %JAVA_MEM_OPTS% %CONFIG_FILES% -cp %CLASSPATH% %MAIN_CLASS%

) else (
echo "Use the inner package jdk to start"

start %INNER_EXE% %JAVA_OPTS% %JAVA_MEM_OPTS% %CONFIG_FILES% -jar %DEPLOY_DIR%\%JAR_NAME%
start %INNER_EXE% %JAVA_OPTS% %JAVA_MEM_OPTS% %CONFIG_FILES% -cp %CLASSPATH% %MAIN_CLASS%
)

echo "Service Start Success!"
Expand Down
8 changes: 5 additions & 3 deletions script/assembly/collector/bin/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ if [ -n "$SERVER_PORT" ]; then
fi
fi
fi

MAIN_CLASS="org.apache.hertzbeat.collector.Collector"
EXT_LIB_PATH="$DEPLOY_DIR/ext-lib"
CLASSPATH="$DEPLOY_DIR/$JAR_NAME:$EXT_LIB_PATH/*"
# 项目日志输出绝对路径
LOGS_DIR=$DEPLOY_DIR/logs
# 如果logs文件夹不存在,则创建文件夹
Expand All @@ -99,15 +101,15 @@ echo -e "Starting the HertzBeat $SERVER_NAME ..."

if [ -f "./java/bin/java" ]; then
echo -e "Use the inner package jdk to start"
nohup ./java/bin/java $JAVA_OPTS $JAVA_MEM_OPTS $CONFIG_FILES -jar $DEPLOY_DIR/$JAR_NAME >logs/startup.log 2>&1 &
nohup ./java/bin/java $JAVA_OPTS $JAVA_MEM_OPTS $CONFIG_FILES $CLASSPATH $MAIN_CLASS >logs/startup.log 2>&1 &
else
JAVA_EXIST=`which java | grep bin | wc -l`
if [ $JAVA_EXIST -le 0 ]; then
echo -e "ERROR: there is no java17+ environment, please config java environment."
exit 1
fi
echo -e "Use the system environment jdk to start"
nohup java $JAVA_OPTS $JAVA_MEM_OPTS $CONFIG_FILES -jar $DEPLOY_DIR/$JAR_NAME >logs/startup.log 2>&1 &
nohup java $JAVA_OPTS $JAVA_MEM_OPTS $CONFIG_FILES $CLASSPATH $MAIN_CLASS >logs/startup.log 2>&1 &
fi

COUNT=0
Expand Down
9 changes: 9 additions & 0 deletions script/assembly/server/assembly-linux-amd64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,14 @@ http://maven.apache.org/ASSEMBLY/2.0.0 ">
<directory>../jdk/linux-amd64</directory>
<outputDirectory>java</outputDirectory>
</fileSet>

<!-- external lib -->
<fileSet>
<directory>../script/ext-lib</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>ext-lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
9 changes: 9 additions & 0 deletions script/assembly/server/assembly-linux-arm64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,14 @@ http://maven.apache.org/ASSEMBLY/2.0.0 ">
<directory>../jdk/linux-arm64</directory>
<outputDirectory>java</outputDirectory>
</fileSet>

<!-- external lib -->
<fileSet>
<directory>../script/ext-lib</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>ext-lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
9 changes: 9 additions & 0 deletions script/assembly/server/assembly-macos-amd64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,14 @@ http://maven.apache.org/ASSEMBLY/2.0.0 ">
<directory>../jdk/macos-amd64</directory>
<outputDirectory>java</outputDirectory>
</fileSet>

<!-- external lib -->
<fileSet>
<directory>../script/ext-lib</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>ext-lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
9 changes: 9 additions & 0 deletions script/assembly/server/assembly-macos-arm64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,14 @@ http://maven.apache.org/ASSEMBLY/2.0.0 ">
<directory>../jdk/macos-arm64</directory>
<outputDirectory>java</outputDirectory>
</fileSet>

<!-- external lib -->
<fileSet>
<directory>../script/ext-lib</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>ext-lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
9 changes: 9 additions & 0 deletions script/assembly/server/assembly-windows-64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,14 @@ http://maven.apache.org/ASSEMBLY/2.0.0 ">
<directory>../jdk/windows-64</directory>
<outputDirectory>java</outputDirectory>
</fileSet>

<!-- external lib -->
<fileSet>
<directory>../script/ext-lib</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>ext-lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
9 changes: 9 additions & 0 deletions script/assembly/server/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,14 @@ http://maven.apache.org/ASSEMBLY/2.0.0 ">
<directory>../web-app/dist</directory>
<outputDirectory>dist</outputDirectory>
</fileSet>

<!-- external lib -->
<fileSet>
<directory>../script/ext-lib</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>ext-lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
6 changes: 4 additions & 2 deletions script/assembly/server/bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ DEPLOY_DIR=`pwd`
# 外部配置文件绝对目录,如果是目录需要/结尾,也可以直接指定文件
# 如果指定的是目录,spring则会读取目录中的所有配置文件
CONF_DIR=$DEPLOY_DIR/config

MAIN_CLASS="org.apache.hertzbeat.manager.Manager"
EXT_LIB_PATH="$DEPLOY_DIR/ext-lib"
CLASSPATH="$DEPLOY_DIR/$JAR_NAME:$EXT_LIB_PATH/*"
# 项目日志输出绝对路径
LOGS_DIR=$DEPLOY_DIR/logs
# 如果logs文件夹不存在,则创建文件夹
Expand All @@ -58,4 +60,4 @@ then
fi
CONFIG_FILES=" -Dlogging.path=$LOGS_DIR $LOGGING_CONFIG -Dspring.config.location=$CONF_DIR/ "
echo -e "Starting the HertzBeat $SERVER_NAME ..."
java $JAVA_OPTS $JAVA_MEM_OPTS $CONFIG_FILES -jar $DEPLOY_DIR/$JAR_NAME --spring.profiles.active=prod
java $JAVA_OPTS $JAVA_MEM_OPTS $CONFIG_FILES -cp $CLASSPATH $MAIN_CLASS --spring.profiles.active=prod
8 changes: 5 additions & 3 deletions script/assembly/server/bin/startup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ for /f "tokens=1-5" %%i in ('netstat -ano^|findstr "0.0.0.0:%SERVER_PORT%"') do
echo exit!
goto q
)

set MAIN_CLASS=org.apache.hertzbeat.manager.Manager
set LOGS_DIR=%DEPLOY_DIR%\logs
set EXT_LIB_PATH=%DEPLOY_DIR%\ext-lib
set CLASSPATH=%DEPLOY_DIR%\%JAR_NAME%;%EXT_LIB_PATH%\*

if not exist %LOGS_DIR% (
mkdir %LOGS_DIR%
Expand All @@ -65,12 +67,12 @@ set INNER_EXE=%DEPLOY_DIR%\java\bin\javaw.exe
if not exist %INNER_EXE% (
echo "Use the system environment jdk to start"

start javaw %JAVA_OPTS% %JAVA_MEM_OPTS% %CONFIG_FILES% -jar %DEPLOY_DIR%\%JAR_NAME%
start javaw %JAVA_OPTS% %JAVA_MEM_OPTS% %CONFIG_FILES% -cp %CLASSPATH% %MAIN_CLASS%

) else (
echo "Use the inner package jdk to start"

start %INNER_EXE% %JAVA_OPTS% %JAVA_MEM_OPTS% %CONFIG_FILES% -jar %DEPLOY_DIR%\%JAR_NAME%
start %INNER_EXE% %JAVA_OPTS% %JAVA_MEM_OPTS% %CONFIG_FILES% -cp %CLASSPATH% %MAIN_CLASS%
)

echo "Service Start Success!"
Expand Down
10 changes: 7 additions & 3 deletions script/assembly/server/bin/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,18 @@ if [ -n "$SERVER_PORT" ]; then
fi
fi
fi

MAIN_CLASS="org.apache.hertzbeat.manager.Manager"
EXT_LIB_PATH="$DEPLOY_DIR/ext-lib"
CLASSPATH="$DEPLOY_DIR/$JAR_NAME:$EXT_LIB_PATH/*"
# 项目日志输出绝对路径
LOGS_DIR=$DEPLOY_DIR/logs
# 如果logs文件夹不存在,则创建文件夹
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi



# JVM Configuration
JAVA_OPTS=" -Duser.timezone=Asia/Shanghai -Doracle.jdbc.timezoneAsRegion=false"

Expand All @@ -99,15 +103,15 @@ echo -e "Starting the HertzBeat $SERVER_NAME ..."

if [ -f "./java/bin/java" ]; then
echo -e "Use the inner package jdk to start"
nohup ./java/bin/java $JAVA_OPTS $JAVA_MEM_OPTS $CONFIG_FILES -jar $DEPLOY_DIR/$JAR_NAME >logs/startup.log 2>&1 &
nohup ./java/bin/java $JAVA_OPTS $JAVA_MEM_OPTS $CONFIG_FILES -cp $CLASSPATH $MAIN_CLASS >logs/startup.log 2>&1 &
else
JAVA_EXIST=`which java | grep bin | wc -l`
if [ $JAVA_EXIST -le 0 ]; then
echo -e "ERROR: there is no java17+ environment, please config java environment."
exit 1
fi
echo -e "Use the system environment jdk to start"
nohup java $JAVA_OPTS $JAVA_MEM_OPTS $CONFIG_FILES -jar $DEPLOY_DIR/$JAR_NAME >logs/startup.log 2>&1 &
nohup java $JAVA_OPTS $JAVA_MEM_OPTS $CONFIG_FILES -cp $CLASSPATH $MAIN_CLASS >logs/startup.log 2>&1 &
fi

COUNT=0
Expand Down
21 changes: 21 additions & 0 deletions script/ext-lib/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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.

Please move external libs to this folder like:

ojdbc8-21.5.0.0.jar
orai18n-21.5.0.0.jar
mysql-connector-java-8.0.30.jar

Loading