• SprintBoot项目服务启停脚本


    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包的名称

  • 相关阅读:
    C# 基于密钥的64位加密与解密方法(原创)
    爱情 前途 命运
    设计模式学习笔记装饰模式
    jquery暂无图片插件
    IIS GZIP压缩(转)
    Fckeditor使用笔记
    设计模式学习笔记策略模式
    电子商务网站搜索架构方案
    批量修改数据库表的架构sql
    win 2003 安装 vs2005 sp1 问题1718
  • 原文地址:https://www.cnblogs.com/malukang/p/13494889.html
Copyright © 2020-2023  润新知