springboot运行脚本

springboot运行脚本(linux版本)

/usr/local/springboot 为jar所在目录
/usr/local/java/jdk1.8.0_171 jdk安装目录
hrk-ump-rpc-service-1.0.0.jar jar包名称
ProvidersApplication.out 日志文件
server1.pid 存放pid的文件

#! /bin/bash
# 当前文件路径
SERVER=/usr/local/springboot
cd $SERVER

start(){
    echo "启动"
        #jdk 安装目录
    JAVA_HOME=/usr/local/java/jdk1.8.0_171
    export JAVA_HOME
    PATH=$JAVA_HOME/bin:.:$PATH
    export PATH
    cd /usr/local/springboot
  
   classPath1="./hrk-ump-rpc-service-1.0.0.jar"
    nohup java  -Dfile.encoding=utf-8 -cp $classPath1 -Djava.security.policy=email_server-security.policy -jar hrk-ump-rpc-service-1.0.0.jar > ProvidersApplication.out 2>&1 &
    echo $! > $SERVER/server1.pid
    echo "启动ProvidersApplication成功"

   
}

stop(){
    echo "暂停"
    if [ ! -d "$SERVER/server1.pid" ]; then
      kill `cat $SERVER/server1.pid`
      rm -rf $SERVER/server1.pid
      echo "暂停成功"
    else
      echo "没有进程可以杀死"
    fi
}


restart(){
    echo "开始重新部署"
    stop
    sleep 1
    start
}


restart

你可能感兴趣的:(javase,总结)