• 无感知的热部署切换


    cd distribution-service-sdk
    mvn -s /root/maven/settings-dev.xml -gs /root/maven/settings-dev.xml deploy
    
    #echo "kill 99jar包"
    ID=`ps -ef | grep java | grep distribution-service-99 |awk '{print $2}'`
    CURPROT=0
    DEFULTPORT=99
    for id in $ID 
    do 
        CURPROT=99
        #echo "killed pid=$id" 
    done
    
    if [ $CURPROT == $DEFULTPORT ];then
       ID88=`ps -ef | grep java | grep distribution-service-88 |awk '{print $2}'`
      for id in $ID88
      do 
          echo "88与99同时运行中,杀掉88,更新88为最新版本"
         echo "killed pid=$id"
         kill -9 $id      
      done
    
      echo "删除88jar包 "
      rm -rf /root/newProject/services/distribution-service-88.jar
      rm -rf /root/newProject/services/distribution-service-88.log
      sleep 2
      echo "复制88jar包"
      cp -r /var/lib/jenkins/workspace/distribution-service/distribution-service-publish/target/distribution-service-publish-1.0.0-SNAPSHOT.jar /root/newProject/services
      mv /root/newProject/services/distribution-service-publish-1.0.0-SNAPSHOT.jar /root/newProject/services/distribution-service-88.jar
      echo "执行后台启动88jar包"
      export BUILD_ID=dontKillMe
      nohup java -jar /root/newProject/services/distribution-service-88.jar --spring.profiles.active=test --server.port=88 >> /root/newProject/services/distribution-service-88.log&
      tail -f /root/newProject/services/distribution-service-88.log | sed '/Tomcat started on port/ q'
      echo "处理nginx,负载到88"
      mv /usr/local/nginx/conf/host_config/distribution-service-99.conf /usr/local/nginx/conf/host_config/distribution-service-99.conf.bak
      mv /usr/local/nginx/conf/host_config/distribution-service-88.conf.bak /usr/local/nginx/conf/host_config/distribution-service-88.conf
      /usr/local/nginx/sbin/nginx -s reload
      for id in $ID 
      do 
          echo "killed pid=$id" 
        kill -9 $id
      done
      exit 0
    else
      echo "删除99jar包 "
      rm -rf /root/newProject/services/distribution-service-99.jar
      rm -rf /root/newProject/services/distribution-service-99.log
      sleep 2
      echo "复制99jar包"
      cp -r /var/lib/jenkins/workspace/distribution-service/distribution-service-publish/target/distribution-service-publish-1.0.0-SNAPSHOT.jar /root/newProject/services
      mv /root/newProject/services/distribution-service-publish-1.0.0-SNAPSHOT.jar /root/newProject/services/distribution-service-99.jar
      echo "执行后台启动99jar包"
      export BUILD_ID=dontKillMe
      nohup java -jar /root/newProject/services/distribution-service-99.jar --spring.profiles.active=test --server.port=99 >> /root/newProject/services/distribution-service-99.log&
      tail -f /root/newProject/services/distribution-service-99.log | sed '/Tomcat started on port/ q'
      echo "处理nginx,负载到99"
      mv /usr/local/nginx/conf/host_config/distribution-service-88.conf /usr/local/nginx/conf/host_config/distribution-service-88.conf.bak
      mv /usr/local/nginx/conf/host_config/distribution-service-99.conf.bak /usr/local/nginx/conf/host_config/distribution-service-99.conf
      /usr/local/nginx/sbin/nginx -s reload
      ID=`ps -ef | grep java | grep distribution-service-88 |awk '{print $2}'`
      CURPROT=0
      for id in $ID 
      do 
          #CURPROT=88
          echo "killed pid=$id" 
          kill -9 $id
         
      done
    sleep 5
    exit 0
    
    
    fi 
  • 相关阅读:
    用函数装饰一首诗
    [转]最常用的15大Eclipse开发快捷键技巧
    [转]python 模块 chardet下载及介绍
    python手动设置递归调用深度
    view-xpath
    开源项目的贡献流程
    MIT许可证
    scrapy分布式的几个重点问题
    【bzoj1026】[SCOI2009]windy数 数位dp
    【bzoj5064】B-number 数位dp
  • 原文地址:https://www.cnblogs.com/zhiji6/p/10119147.html
Copyright © 2020-2023  润新知