代码拉取完成,页面将自动刷新
#!/bin/sh
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
workspace="$(cd "$(dirname "$0")" && pwd -P)"
cd "${workspace}"
app=springboot-demo.jar
logfile=var/app.log
pidfile=var/app.pid
cfg=dev
JVM_ARGS="-server -Xms2G -Xmx2G -XX:+UseG1GC -XX:+DisableExplicitGC -XX:MaxGCPauseMillis=500 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC -Djava.awt.headless=true -Xloggc:logs/gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=logs -XX:ErrorFile=logs/hs_err_pid%p.log"
#默认使用dev的配置
function setconfig(){
local clusterfile="$workspace/.deploy/service.cluster.txt"
if [[ -f "$clusterfile" ]]; then
local cluster=`cat $clusterfile`
if [ $cluster == "hnc-pre-v" ]; then
cfg="pre"
elif [ $cluster == "hnc-v" ]; then
cfg="prod"
fi
else
echo "set config error:$clusterfile "
fi
}
start() {
setconfig
exec java -jar ${JVM_ARGS} -Dspring.profiles.active=${cfg} ${workspace}/springboot-demo.jar > /dev/null 2>&1
}
stop() {
i=0
while [ $i -lt 60 ]; do
if check_pid; then
echo "" >${pidfile}
echo "${app} is stopped"
exit 0
fi
pid="$(get_pid)"
if [ "x" = "x${pid}" ]; then
echo "${app} is stopped, can't find pid on ${pidfile}"
exit 0
fi
kill "${pid}" >/dev/null 2>&1
if check_pid; then
echo "" >${pidfile}
echo "${app} stop ok"
exit 0
fi
sleep 1
i=$((i + 1))
done
echo "stop timeout"
exit 1
}
status() {
if ! check_pid; then
echo "${app} is started, pid=$(get_pid)"
else
echo "${app} is stopped"
fi
exit 0
}
get_pid() {
pid=""
if [ -f ${pidfile} ]; then
pid=$(cat ${pidfile})
fi
echo "$pid"
}
check_pid() {
pid=$(get_pid)
if [ "x" != "x${pid}" ]; then
# shellcheck disable=SC2009
running=$(ps -p "${pid}" | grep -c -v "PID TTY")
return "${running}"
fi
return 0
}
action=$1
case ${action} in
"start")
start
;;
"stop")
stop
;;
"status")
status
;;
*)
echo "unknown command"
exit 1
;;
esac
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。