vim start_boot.sh

#!/bin/bash

usage(){
echo "$0 [start|stop|usage]"
}

status_springboot(){
ps axu | grep "${jar_file}" | grep -v 'grep'
}
start_springboot(){
echo "springboot start"
#if [ `hostname` = "${jar_menu}01"  ]
#then
nohup java -server -Xmx${MEM_SIZE}m -Xms${MEM_SIZE}m  -Dio.netty.leakDetection.level=advanced -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -jar ${jar_file} > /dev/null 2>&1 &
#else
nohup java -server -Xmx${MEM_SIZE}m -Xms${MEM_SIZE}m  -Dio.netty.leakDetection.level=advanced -XX:+UseG1GC -XX:MaxGCPauseMillis=100  -jar ${jar_file} > /dev/null 2>&1 &
#fi
}

stop_springboot(){
springboot_pid=` ps axu | grep "${jar_file}" | grep -v 'grep' | awk '{print $2}'`
kill -9 $springboot_pid
sleep 5;
TSTAT=$(ps axu | grep "${jar_file}" | grep -v 'grep' | awk '{print $2}')
if [ -z $TSTAT ];then
echo "springboot stop"
else
kill -9 $TSTAT
fi
}

function main(){

jar_menu=`hostname | cut -d"0" -f1`
[ -d /data/work/${jar_menu} ] || { echo -e "menu is not exist";exit 2; }
data_path="/data/work/${jar_menu}"
cd ${data_path}
jar_file=`ls -lrt *.jar | tail -1 | awk '{print $9}'`

#############judge jvm memory#######
total_memory=$(vmstat -s -S M|awk 'NR==1{print $1}')
avi_mem_size=$((${total_memory}/1024))
if [ ${avi_mem_size} -gt 6 ];then
MEM_SIZE="4096"
elif [ ${avi_mem_size} -le 4 ];then
MEM_SIZE="2048"
fi
echo ${MEM_SIZE}
case $1 in

start)
start_springboot
;;
stop)
stop_springboot
;;
status)
status_springboot
;;
restart)
stop_springboot
sleep 5
start_springboot
;;
*)
usage
;;
esac

}
main $1

最新文章

  1. 手把手教你使用Git
  2. Spring+SpringMVC+MyBatis+Maven 服务端XML配置
  3. markdown编辑器使用建议
  4. Uva 10917
  5. bin和sbin的区别
  6. jQuery的deferred对象
  7. backbonejs mvc框架的增删查改实例
  8. MySQL冷备份的跨操作系统还原
  9. php预定义常量&变量
  10. Android实战技巧: ListView之ContextMenu无法弹出
  11. arcgis jsapi 调用google地区服务
  12. Dotfuscator注册码和XenoCode注册码
  13. SlidingMenu的使用,结合Fragment(eclipse环境)
  14. Error: Cannot find module 'gulp-clone'问题的解决
  15. BZOJ 2809: [Apio2012]dispatching [斜堆]
  16. Request中Attribute 和 Parameter 的区别
  17. BUG调试: Jump to the invalid address stated on the next line at 0x0: ???
  18. drf2 FBV和CBV
  19. Windows查看端口被什么进程占用的简单方法----菜鸟养成
  20. git排除常用配置,svn与git共存时.gitignore配置

热门文章

  1. javascript 学习犯错记录
  2. Spring对junit的整合
  3. ros机器人导航设置原点,目标点
  4. vim 中 ctags的应用
  5. JS window对象 计时器setTimeout() setTimeout()计时器,在载入后延迟指定时间后,去执行一次表达式,仅执行一次。 语法: setTimeout(代码,延迟时间);
  6. PushSharp 由于远程方已关闭传输流,身份验证失败。
  7. Python学习笔记(八)——正则表达式
  8. notepad++去换行(简单、快捷)
  9. H5调用百度地图导航
  10. leetcood学习笔记-113-路径总和 II