WechatGroup
This commit is contained in:
61
buildAndStart.sh
Normal file
61
buildAndStart.sh
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
_math() {
|
||||
_m_opts="$@"
|
||||
printf "%s" "$(($_m_opts))"
|
||||
}
|
||||
|
||||
#输出绿色文字
|
||||
__green() {
|
||||
printf '\33[1;32m%b\33[0m' "$1" "\n"
|
||||
return
|
||||
}
|
||||
|
||||
#输出红色文字
|
||||
__red() {
|
||||
printf '\33[1;31m%b\33[0m' "$1" "\n"
|
||||
return
|
||||
}
|
||||
__kill() {
|
||||
PID=`ps -ef | grep ${1}.jar | grep -v grep |awk '{print $2}' | xargs`
|
||||
sleepSeconds=10
|
||||
curSleepSecond=1
|
||||
while [[ -n "$PID" && "$sleepSeconds" -ge "$curSleepSecond" ]]; do
|
||||
__green "尝试kill PID : ${PID}"
|
||||
if [ "$sleepSeconds" -eq "$curSleepSecond" ]; then
|
||||
__red "强制关闭: ${curSleepSecond}"
|
||||
kill -9 $PID >> /dev/null 2>&1
|
||||
fi
|
||||
kill $PID >> /dev/null 2>&1
|
||||
__green "停止程序计时:${curSleepSecond}秒"
|
||||
sleep 1
|
||||
curSleepSecond="$(_math "$curSleepSecond" + 1)"
|
||||
PID=`ps -ef | grep ${1}.jar | grep -v grep |awk '{print $2}' | xargs`
|
||||
done
|
||||
}
|
||||
|
||||
source /etc/profile
|
||||
git --git-dir=/root/backend/.git --work-tree=/root/backend fetch origin main
|
||||
git --git-dir=/root/backend/.git --work-tree=/root/backend reset --hard origin/main
|
||||
git --git-dir=/root/backend/.git --work-tree=/root/backend pull origin main
|
||||
#################################################### 配置 ##############################################################
|
||||
BASE_PATH=/root/backend
|
||||
modelName=backend
|
||||
profile=dev
|
||||
JVM_MEMERY=" -Xms256M -Xmx256M -XX:MaxDirectMemorySize=256M"
|
||||
# JVM_OPTION="${JVM_MEMERY} -XX:MetaspaceSize=64M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/root/backend/logs/heap_dump_${modelName}.hprof -verbose:gc -XX:+PrintGCDateStamps -XX:+PrintGCDetails -Xloggc:/data0/logs/gc_${modelName}.log -server -Djava.security.egd=file:/dev/./urandom"
|
||||
DES_PATH=/root/backend
|
||||
JAR=${DES_PATH}/ruoyi-admin/target/ruoyi-admin.jar
|
||||
LOG_BACK_LOG=/root/backend/logs/back/${modelName}-info.log
|
||||
LOG=/root/backend/logs/${modelName}.log
|
||||
SELF_IP=$(ifconfig | grep "10.0.0" | awk '{print $2}' | cut -d ':' -f 2 |head -n 1)
|
||||
if [[ "${SELF_IP}" == "" ]] ;then
|
||||
SELF_IP=$(ifconfig -a | grep -E '172.|10.|192.' | grep -E 'Bcast|broadcast' | grep -E 'Mask|netmask' | awk '{print $2}' | cut -d ':' -f 2 |head -n 1)
|
||||
fi
|
||||
#################################################### 构建 ############################################################
|
||||
cd /root/backend && mvn clean && mvn install -T 4
|
||||
pkill -f /root/backend/ruoyi-admin/target/ruoyi-admin.jar
|
||||
nohup java ${JVM_OPTION} -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=6011 -jar ${JAR} --spring.profiles.active=${profile} >> ${LOG} 2>&1 &
|
||||
tail -f /root/backend/logs/backend.log
|
||||
#################################################### 启动 ##############################################################
|
Reference in New Issue
Block a user