zoukankan      html  css  js  c++  java
  • 自动部署war包脚本

    war 包所在路径为:/home/wars/ROOT.war

    tomcat 所在路径为:

    ①:/home/search-3

    ②:/home/search-4

    部署单个war到一个tomcat中

    #!/bin/sh
    TOMCAT='/home/search-3'
    echo "deploy ROOT.war"
    
    #ps 显示进程,grep筛选进程,awk是一个强大的文本分析工具筛选出tomcat8的pid
    pidList=`ps -ef|grep search-3|grep -v 'grep'|awk '{print $2'}`
    echo "${pidList}"
    if [ "$pidList" = "" ]; then
      echo "no tomcat pid alive"
     else
    #kill掉tomcat的进程
      echo "tomcat id list :$pidList"
      kill -9 $pidList
      echo "kill $pidList"
    fi
    echo "begin del old ROOT.war"
    #移除原来的war包
    rm -rf $TOMCAT/webapps/ROOT.war && rm -rf $TOMCAT/webapps/ROOT
    echo "copy to tomcat webApps "
    #拷贝war包到tomcat启动目录下
    cp /home/wars/ROOT.war $TOMCAT/webapps/
    #启动tomat
    echo "start tomcat ! Go Go Go!!!"
    cd $TOMCAT"/bin"
    ./startup.sh
    

      部署同一个war到一两个不同的tomcat中,两个以上,直接修改数组即可

    #!/bin/sh
    tomcats=('/search-3' '/search-4')
    echo "deploy ROOT.war"
    for tomcat in ${tomcats[@]}
    do
        pidList=`ps -ef|grep $tomcat|grep -v 'grep'|awk '{print $2'}`
        echo "${pidList}"
        if [ "$pidList" = "" ]; then
         echo "no tomcat pid alive"
        else
         echo "tomcat id list :$pidList"
         kill -9 $pidList
         echo "kill $pidList"
    fi
    echo "begin del old ROOT.war"
    rm -rf '/home'$tomcat/webapps/ROOT.war && rm -rf '/home'$tomcat/webapps/ROOT
    echo "copy to tomcat webApps "
    cp /home/wars/ROOT.war '/home'$tomcat/webapps/
    echo "start tomcat ! Go Go Go!!!"
    cd '/home'$tomcat"/bin"
    ./startup.sh
    
    done
    

      

  • 相关阅读:
    字符串算法总结
    [HAOI2007]反素数
    Poj2689 Prime Distance
    [APIO2010]特别行动队
    [国家集训队]middle
    Typecho博客迁移实战
    Typora + 七牛云图床 简易配置
    教你用快捷键 以管理员身份运行cmd
    Typecho博客插入B站视频
    七牛云图床快捷上传方法
  • 原文地址:https://www.cnblogs.com/dongma/p/9850325.html
Copyright © 2011-2022 走看看