• Jenkins 配置


    #!/bin/bash
    
    source /etc/profile
    
    #sh /opt/service/9-com-ycg-rosefinch-bos-data/op-srm-test-service-9-com-ycg-rosefinch-op-api.sh start
    #sleep 3
    #sh /opt/service/14-com-ycg-rosefinch-op-route/op-vms-test-service-14-com-ycg-rosefinch-op-route.sh start
    #sleep 3
    #sh /opt/service/16-1-com-ycg-rosefinch-vms/op-vms-test-service-16-1-com-ycg-rosefinch-vms.sh start
    basepath=$(cd `dirname $0`; pwd)  
    echo $basepath
    
    cd $basepath
    #rm -rf ./logs/*
    #stop service 
    if [ -d ./query ]; then
         killjarfile=''
         for file in ./query/*
             do
               if [ -f $file ]; then
                    jfile=$(echo $file | grep .jar)
                    if [[ $jfile != "" ]]; then
                       killjarfile=${jfile:2}
                    fi
               fi
             done
    
        let length=${#killjarfile}-4
        echo 'length>'$length
        pidstr=${killjarfile:0:30}.pid
        pidstr=${pidstr:6}
        echo 'pidstr>'$pidstr
    
        kill `cat query/$pidstr`
        rm -rf $pidstr
        echo "=== stop $SERVICE_NAME"
    
        SERVICE_NAME=${killjarfile:0:30}
        SERVICE_NAME=$pidstr    
        let lng=${#SERVICE_NAME}-4;
        SERVICE_NAME=${SERVICE_NAME:0:lng}
    
        sleep 5
            P_ID=`ps -ef | grep -w "$SERVICE_NAME" | grep -v "grep" | awk '{print $2}'`
            if [ "$P_ID" == "" ]; then
                echo "=== $SERVICE_NAME process not exists or stop success"
            else
                echo "=== $SERVICE_NAME process pid is:$P_ID"
                echo "=== begin kill $SERVICE_NAME process, pid is:$P_ID"
                kill -9 $P_ID
            fi
            
    fi
    
    if [ -d ./query ]; then
         echo "开始删除query文件夹"
         rm -rf "query"
         echo "删除文件夹结束"
    fi
    zipfile=''
    
    for file in ./*
    do
        if [ -f $file ]; then
        #if test -f $file then
            result=$(echo $file | grep .zip);
               if [[ $result != "" ]]; then
           zipfile=${result:2}
        fi 
        fi
    done
    
    
    unzip $zipfile
    
    jarfile=''
    for file in ./query/*
    do
        if [ -f $file ]; then
        jfile=$(echo $file | grep .jar)
        if [[ $jfile != "" ]]; then
            jarfile=${jfile:2}
        fi
        fi
    done
    
    let length=${#jarfile}-4
    echo 'length>'$length
    pidstr=${jarfile:0:30}
    echo 'pidstr>'$pidstr
    
    nohup java -Xms256m -Xmx256m -jar $basepath/$jarfile >/dev/null 2>&1 &
    echo $! > $pidstr.pid
    
    echo '###############################'
    echo $jarfile' is running'
    echo '###############################'


    下面是WEB配置

    #!/bin/bash
    
    
    TOMCAT_HOME="$3"
    TOMCAT_PORT="$2"
    PROJECT="$1"
    source /etc/profile
    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
    
    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
    rm -rf "$TOMCAT_HOME"/logs/*
    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"
  • 相关阅读:
    2010年Ei收录的中国期刊
    做DSP最应该懂得157个问题
    【资料分享】 OpenCV精华收藏
    孙鑫VC学习笔记:多线程编程
    对Davinci DM6446的评价[转]
    TI首席科学家展望2020年处理器架构和DSP的发展
    37份计算机科学的经典文档
    VC学习笔记:状态栏
    【VC参考手册】MFC类库:4.21版和6.0版
    TI DSP入门学习
  • 原文地址:https://www.cnblogs.com/acme6/p/9411574.html
Copyright © 2020-2023  润新知