zoukankan      html  css  js  c++  java
  • jenkins-tomcat

    exec command

    target/*.war

    /opt/tomcat-8080(无用)

    /opt/tomcatDeploy.sh rosefinch-web   8080 /opt/tomcat-8080

    #!/bin/bash
    
    #默认变量值
    TOMCAT_HOME="$3"
    TOMCAT_PORT="$2"
    PROJECT="$1"
    source /etc/profile
    #参数检验./deploy.sh <projectname> [tomcat port] [tomcat home dir]
    if [ $# -lt 1 ]; then
      echo "you must use like this : ./deploy.sh <projectname> [tomcat port] [tomcat home dir]"  
      exit
    fi
    if [ ! -n "$2" ]; then
       TOMCAT_PORT=$2
    fi
    if [ ! -n "$3" ]; then
       TOMCAT_HOME="$3"
    fi
    
    #根据端口查找tomcatpid,可能有多个,循环中判断
    tomcat_pid=`netstat -anp | grep $TOMCAT_PORT | awk '{printf $7}' | cut -d "/" -f 1`
    echo "current :" $tomcat_pid
    while [ -n "$tomcat_pid" ]
    do
     sleep 5
     #进一步筛选
     tomcat_pid=`ps -ef | grep $tomcat_pid |grep $TOMCAT_HOME | grep -v 'grep|tail|more|bash|less'| awk '{print $2}'`
     echo "scan tomcat pid :" $tomcat_pid
     if [ -n "$tomcat_pid" ]; then
       echo "kill tomcat :" $tomcat_pid
       kill -9 $tomcat_pid
     fi
    done
    
    #备份路径
    #BAK_DIR=$HOME/war/bak/$PROJECT/`date +%Y%m%d`
    #mkdir -p "$BAK_DIR"
    #cp "$TOMCAT_HOME"/webapps/$PROJECT.war "$BAK_DIR"/"$PROJECT"_`date +%H%M%S`.war
    
    #publish project
    echo "scan no tomcat pid,$PROJECT publishing"
    rm -rf "$TOMCAT_HOME"/webapps/$PROJECT
    rm -rf "$TOMCAT_HOME"/webapps/$PROJECT.war
    cp /opt/war/$PROJECT.war "$TOMCAT_HOME"/webapps/$PROJECT.war
    
    #remove tmp
    rm -rf /opt/war/$PROJECT.war
    #start tomcat
    "$TOMCAT_HOME"/bin/startup.sh 
    echo "tomcat is starting,please try to access $PROJECT conslone url"
    

      

  • 相关阅读:
    python爬虫 -掘金
    python 爬取简书评论
    python爬取知乎评论
    python 爬取链家
    python爬虫获取下一页
    python正则找到字符串里面的数字
    faker切换user-agent
    python 爬虫可视化函数,可以先看看要爬取的数据是否存在
    acwing 471. 棋盘 解题记录
    ACWING 95 费解的开关 解题记录
  • 原文地址:https://www.cnblogs.com/zfzf1/p/8392250.html
Copyright © 2011-2022 走看看