SprintBoot项目服务启停脚本

标签:RKE   div   else   admin   run   fun   collect   rip   install   

SprintBoot项目服务启停脚本

vim springboot.sh 

#!/bin/bash
export BUILD_ID=DONTKILLME

APP_NAME=$2
#APP_NAME=admin-1.0-SNAPSHOT

function stop(){
  PID=`ps -ef|grep $APP_NAME|grep -v grep|grep -v $0|awk {print $2}`
  if [[ -n "$PID" ]];then
      echo Stop Process...
      kill -15 $PID
  fi
  PID=`ps -ef|grep $APP_NAME|grep -v grep|grep -v $0|awk {print $2}`
  if [[ -n "$PID" ]];then
      echo "PID: $PID"
      echo Kill Process!.....
      kill -9 $PID
  else
      echo No pid, No process,Stop Success!....
  fi
}


function start(){
#  java -version
  if [ $? = 0 ];then
    ## nohup java -jar ${APP_NAME}.jar --spring.config.location=conf/application.yml > /dev/null 2>&1 &
    JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
    JAVA_MEM_OPTS=" -server  -Xmx512m -Xms512m -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "

    nohup java $JAVA_OPTS $JAVA_MEM_OPTS -jar ${APP_NAME}.jar --spring.profiles.active=dev > /dev/null 2>&1 &
    echo $! $?
    echo Start Success!
  else
      echo "java is not installed"
  fi

}


function status(){
   PID=`ps -ef|grep $APP_NAME|grep -v grep|grep -v $0|awk {print $2}`
   if [[ -n "$PID" ]]; then
       echo "PID:$PID"
       echo "$APP_NAME is running."
   else
       echo "$APP_NAME is downing."
   fi
}

## 入口
case $1 in
 start)
    start
    ;;
 stop)
    stop
    ;;
 status)
     status
     ;;
 *)
    echo "./springboot.sh start/stop/status jar-package-name"
    ;;

esac

exit 0

脚本使用:

  sh springboot.sh ($1)stop ($2)admin-1.0-SNAPSHOT

  $1 为start stop status

  $2 为启动的jar包的名称

 

SprintBoot项目服务启停脚本

标签:RKE   div   else   admin   run   fun   collect   rip   install   

原文地址:https://www.cnblogs.com/malukang/p/13494889.html

版权声明:完美者 发表于 2020-08-13 12:45:24。
转载请注明:SprintBoot项目服务启停脚本 | 完美导航

暂无评论

暂无评论...