Ai
2 Star 1 Fork 0

沈沈/springboot_demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
control.sh 2.32 KB
一键复制 编辑 原始数据 按行查看 历史
shenning 提交于 2021-08-02 11:17 +08:00 . 打包
#!/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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/snwd/springboot_demo.git
git@gitee.com:snwd/springboot_demo.git
snwd
springboot_demo
springboot_demo
master

搜索帮助