• 山田预发环境发布脚本


    1.脚本发布

    发布服务器:山田master 

    脚本路径:/server/tools

    Master脚本结构:

    master备份文件在:/server/tools/backup

    backup备份都在文件在:/server/backup

    脚本使用方法:

    [root@iZ6weirh18lb3sov6mfxftZ tools]# sh release.sh
    Usage: release.sh [ deploy | rollback ] 目前可选择deokiy
    [root@iZ6weirh18lb3sov6mfxftZ tools]# sh release.sh deploy  该脚本存在加锁限制  只可同时执行一个任务

    [root@iZ6weirh18lb3sov6mfxftZ tools]# cat release.sh
    #!/bin/bash
    #v1
    # Date/Time Veriables
    LOG_DATE='date "+%Y-%m-%d"'
    LOG_TIME='date "+%H-%M-%S"'
      
    CDATE=$(date "+%Y-%m-%d")
    CTIME=$(date "+%H-%M-%S")
     
    NODE_LIST="8.209.252.22 47.91.31.1"
    #Shell Env
    SHELL_NAME="release.sh"
    SHELL_DIR="/server/tools"
    SHELL_LOG="${SHELL_DIR}/${SHELL_NAME}.log"
    app_groups="/server/tools/app"
    LOGS="/server/tools/logs/${SHELL_NAME}.log"
    #Code Enb
    index="/usr/share/nginx/html/build"
    app_jar="/usr/local/esl/app"
    start_app="/usr/local/esl"
    LOCK_FILE="/tmp/release.lock"
     
    usage(){
        echo  $"Usage: $0 [ deploy | rollback ]"
    }
    writelog(){
            LOGINFO=$1
            echo "${CDATE} ${CTIME}: ${SHELL_NAME} : ${LOGINFO}" >> ${LOGS}
    }
     
    shell_lock(){
        touch ${LOCK_FILE}
    }
     
    shell_unlock(){
        rm -f ${LOCK_FILE}
    }
    rollback(){
        echo rollback
    }
    code_get(){
        writelog  "Front and back end backup of master"
        echo  Front and back end backup of master
        BACK="/server/tools/backup/html"
        cd $index
        tar zcf dist-$CDATE.tar.gz dist && mv dist-$CDATE.tar.gz $BACK
        Jar_Back="/server/tools/backup/jar"
        mv $app_jar/zk_esl_release.jar $Jar_Back/zk_esl_release$CDATE.jar 
    }
     
    release_push(){
        writelog  "Master front and back end Publishing";
        echo "Master front and back end Publishing "
        #rm -rf $app_jar/zk_esl_release.jar
        cp $app_groups/zk_esl_release.jar $app_jar
        #echo "Master发布前端"
        cd $index pwd && rm -rf dist
        tar xf  $app_groups/dist.tar.gz -C $index
    }
    code_scp(){
        writelog  "Start synchronously from the server jar package";
        ansible app -m copy -a "src=/usr/local/esl/app/zk_esl_release.jar dest=/server/backup backup=yes"
        ansible app -m file -a 'path=/usr/local/esl/app/zk_esl_release.jar state=absent'
        echo code_scp
        for node in $NODE_LIST;do
          scp $app_groups/zk_esl_release.jar    $node:/usr/local/esl/app/
        done
    }
     
    eslapp_start(){
      writelog "master backup01 backup02 Start Application"
      ansible start -m shell -a 'cd /usr/local/esl/ && docker-compose up -d --build'
    }
     
    main(){
        if [ -f ${LOCK_FILE} ];then
        echo "Deploy is running"  && exit;
        fi
        DEPLOY_METHOO=$1
     
        case $DEPLOY_METHOO in
        deploy)
               shell_lock;
               code_get;
               release_push;
               code_scp;
               eslapp_start;
            shell_unlock;
                ;;
        rollback)
                rollback;
                ;;
        *)
                usage;
        esac
    }
    main $1

    2.jenkins 调用脚本发布

       通过Jenkins执行前后端job即可

  • 相关阅读:
    肯恩·威尔伯:整合灵性途径的几大障碍
    金刚经里面的「应无所住而生其心」,这句话怎么理解?
    成熟是人一辈子的修养,与年龄无关
    杰克·康菲尔德:灵性成熟的十个特质
    杰克·康菲尔德:我是谁?(强烈推荐)
    x11vnc:利用远程机器上的X-Server来进行VNC连接(x11vnc 和 x-server 在不同的机器上)
    Linux ALL:Tigervnc-Server
    Centos 6/Redhat 6:远程图形桌面: tigervnc
    Fedora 31 :远程图形桌面: tigervnc
    win server 2019 :【2个?远程管理用户(单会话?)】升级为远程桌面服务【多用户(多会话)】
  • 原文地址:https://www.cnblogs.com/sseban/p/13750475.html
Copyright © 2020-2023  润新知