代码拉取完成,页面将自动刷新
#!/bin/bash
jarfile="target/blog-1.3.0-GA.jar"
app_args="--spring.profiles.active=product --server.port=9090"
# jvm选项参数
jvm_options="-Xmx2g -Xms128m -Xss512k -XX:+UseG1GC -XX:MaxGCPauseMillis=10 -XX:+HeapDumpOnOutOfMemoryError -XX:+HeapDumpBeforeFullGC -XX:HeapDumpPath=jvm/heap.dump -Xlog:gc*=debug,gc+task*=info:file=jvm/gc%t.log:utctime,level,tags:filecount=50,filesize=100M"
# jvm日志输出目录
jvmLogDir="jvm"
if [ ! -e ${jvmLogDir} ]
then
mkdir -m 664 ${jvmLogDir}
fi
pid=`ps -ef | grep "${jarfile}" | grep -v grep| awk '{print $2}'` # 现存服务的pid
function start_func(){
echo "即将启动服务: ${jarfile}"
if [ -z "${pid}" ] # 检查字符串是否为空
then
echo "nohup java ${jvm_options} -jar ${jarfile} ${app_args} &"
nohup java ${jvm_options} -jar ${jarfile} ${app_args} &
echo "服务启动成功: ${jarfile}"
else
echo "服务早已启动: pid: ${pid}"
fi
ps -ef | grep ${jarfile} | grep -v "grep"
}
function stop_func(){
echo "即将关闭服务: ${jarfile}"
if [ ! -z "${pid}" ] # 检查字符串是否为空
then
echo "关闭服务: ${jarfile}, pid: ${pid}"
kill ${pid}
echo "成功关闭, pid: ${pid}"
pid=""
else
echo "服务不存在: ${jarfile}"
fi
}
if [ $1 = "start" ]
then
start_func
elif [ $1 = "stop" ]
then
stop_func
elif [ $1 = "restart" ]
then
echo "即将重启服务: ${jarfile}"
stop_func
sleep 5s
start_func
else
echo "非法参数"
exit 1
fi # 这个fi必须得有
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。