2022-09-17 17:28:21 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
HOME=$(pwd)
|
|
|
|
JAVA_HOME=${JAVA_HOME:-/opt/jdk}
|
|
|
|
APPLICATION_NAME='io.edurt.datacap.server.DataCap'
|
|
|
|
APPLICATION_PID=
|
|
|
|
|
2023-11-08 15:20:52 +08:00
|
|
|
check_java_version() {
|
|
|
|
local java_version=$("$JAVA_HOME"/bin/java -version 2>&1 | awk -F '"' '/version/ {print $2}')
|
|
|
|
local major_version=$(echo "$java_version" | awk -F. '{print $1}')
|
|
|
|
if [ "$major_version" != "1" ] && [ "$major_version" != "11" ]; then
|
2023-11-08 19:47:57 +08:00
|
|
|
printf "Error: Java version [ %s ] is not supported. Please use Java 1.8 or 11.\n" "$java_version"
|
2023-11-08 15:20:52 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-11-11 14:04:51 +08:00
|
|
|
#获取jvm.conf配置项
|
|
|
|
get_jvm_conf() {
|
|
|
|
printf "\n\tget jvm.conf \n"
|
|
|
|
jvm_conf=`grep -v "^#" $HOME/configure/jvm.conf | awk '/-/{printf $0" "}' `
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-17 17:28:21 +08:00
|
|
|
job_before_echo_basic() {
|
|
|
|
printf "\n\tJob before echo basic \n"
|
|
|
|
printf "============================================\n"
|
|
|
|
printf "Runtime home | %s\n" "$HOME"
|
|
|
|
printf "Runtime java home | %s\n" "$JAVA_HOME"
|
|
|
|
printf "Runtime application name | %s\n" "$APPLICATION_NAME"
|
|
|
|
printf "============================================\n\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
job_before_apply_server() {
|
|
|
|
APPLICATION_PID=$(pgrep -f "$APPLICATION_NAME" | awk '{print $1}')
|
|
|
|
}
|
|
|
|
|
|
|
|
job_runner_checker_server() {
|
|
|
|
printf "\n\tJob runner check server \n"
|
|
|
|
printf "============================================\n"
|
|
|
|
job_before_apply_server
|
|
|
|
printf "Runtime process | %s\n" "$APPLICATION_PID"
|
|
|
|
if test -z "$APPLICATION_PID"; then
|
|
|
|
printf "Server status | %s\n" "stopped"
|
|
|
|
printf "============================================\n\n"
|
|
|
|
else
|
|
|
|
printf "Server status | %s\n" "running"
|
|
|
|
printf "============================================\n\n"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
job_runner_debug_server() {
|
|
|
|
printf "\n\tJob runner server \n"
|
|
|
|
printf "============================================\n"
|
|
|
|
printf "Server starting | %s\n" "$APPLICATION_NAME"
|
|
|
|
cd "$HOME"
|
2023-06-04 14:45:27 +08:00
|
|
|
PLUGIN_DIR=`find plugins/* -type d | sed 's/\(.*\)/\1\/\*/' | xargs | tr ' ' ':'`
|
2023-11-11 14:04:51 +08:00
|
|
|
"$JAVA_HOME"/bin/java -classpath "lib/*:$PLUGIN_DIR" "${jvm_conf}" "$APPLICATION_NAME" \
|
2022-09-17 17:28:21 +08:00
|
|
|
--spring.config.location="$HOME/configure/"
|
|
|
|
}
|
|
|
|
|
2023-11-08 15:20:52 +08:00
|
|
|
check_java_version
|
2022-09-17 17:28:21 +08:00
|
|
|
job_before_echo_basic
|
|
|
|
# shellcheck disable=SC2119
|
|
|
|
job_runner_checker_server
|
|
|
|
job_runner_debug_server
|