• SpringBoot项目从Git拉取代码并完成编译打包启动的sh自动脚本


    操作步骤:

    1.进入/home/servers/codes/xxxx-dev/目录,从git上将项目clone下来;

    2.确保/usr/local/xxx/xxxx-dev目录存在;

    3.确保sh脚本有可执行权限;

    4.执行"sh xxx.sh"命令启动脚本;

    #!/bin/bash 
    #jdk环境变量
    export JAVA_HOME=/usr/java/jdk1.8.0_211-amd64
    export JAVA_BIN=$JAVA_HOME/bin
    export PATH=$PATH:$JAVA_HOME/bin
    export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
    date=`date +%Y%m%d%H%M%S`
    CODE_PATH=/home/servers/codes/xxxx-dev/
    APP_NAME=xxxx-dev.jar
    echo "开始拉取最新代码"
    #首先进行编译
    cd ${CODE_PATH}
    git pull origin dev
    echo "开始编译"
    mvn clean install -Dmaven.test.skip=true -P test
    cd target/
    #执行复制
    mv xxxx-0.0.1-SNAPSHOT.jar ${APP_NAME}
    cp -r ${APP_NAME} /usr/local/xxx/xxxx-dev
    echo "开始进行复制"
    logline=`cat /usr/local/xxx/xxxx-dev/console.log | wc -l`
    #检查程序是否在运行 
    is_exist(){
    pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}' `
    #如果不存在返回1,存在返回0 
    if [ -z "${pid}" ]; then
    return 1
    else
    return 0
    fi
    }
    is_exist
    if [ $? -eq "0" ]; then
    kill -9 $pid
    else
    echo "${APP_NAME} is not running" 
    fi
    cd /usr/local/xxx/xxxx-dev
    is_exist
    if [ $? -eq "0" ]; then
    echo "${APP_NAME} is already running. pid=${pid} ." 
    else
    nohup java -jar ${APP_NAME} >/usr/local/xxx/xxxx-dev/console.log 2>&1 &
    echo "程序已启动..."
    sleep 1;
    tail -10f /usr/local/xxx/xxxx-dev/console.log | sed '/Starting Quartz Scheduler now/Q'
    cat /usr/local/xxx/xxxx-dev/console.log | sed -n ''"$logline"',${/Starting Quartz Scheduler now/, +3p}'
    fi
    is_exist
    if [ $? -eq "0" ]; then
    echo "${APP_NAME} is running. pid is ${pid} "
    else
    echo "${APP_NAME} is not running."
    fi
    exit
  • 相关阅读:
    3.4
    3.3 TensorFlow运行模型 ------- 会话
    3.2 TensorFlow数据模型 ---- 张量
    3.1 TensorFlow计算模型 --- 计算图
    寻找两个有序数组的中位数
    最长子串
    vector的遍历删除
    超时空大决战
    面经七
    面经五
  • 原文地址:https://www.cnblogs.com/jun1019/p/11431054.html
Copyright © 2020-2023  润新知