zoukankan      html  css  js  c++  java
  • soapui_mockservicerunner_script.sh

    转自:https://gist.github.com/apuredol/e22b73d85daa3562e2f0a26ede9fd5e1

    #!/bin/bash
    #
    # Designed for running SoapUI mockservicerunner.sh script in background as command line tool
    # Credits to: tinogomes on github https://gist.github.com/tinogomes/447191
    # References:
    # http://stackoverflow.com/questions/14061876/control-to-the-next-statement-after-running-eval-command
    # http://stackoverflow.com/questions/392022/best-way-to-kill-all-child-processes/6481337#6481337
    # Changes for supporting multiple instances
    
    # Variables to edit according to your environment
    SOAPUI_HOME=$HOME/SoapUI-5.2.1
    PROJECT_HOME=$HOME/somefolder/soap-ui
    USR=`echo whoami`
    # Default variables
    PID=soapui-server.pid
    LOG=soapui-server.log
    if [ -z "$2" ]
    then
      PORT=8080
    else
      PORT=$2
    fi
    
    #Project name containing spaces goes in ""
    COMMAND="$SOAPUI_HOME/bin/mockservicerunner.sh -p $PORT -m "REST MockServices" $PROJECT_HOME/my-project.xml"
    echo "Running "$COMMAND
    
    status() {
        if [ -f $PID ]
        then
            echo
            echo "Pid file: $( cat $PID ) [$PID]"
            echo
            ps -ef | grep -v grep | grep $( cat $PID )
        else
            echo
            echo "No Pid file"
        fi
    }
    
    start() {
      if [ -f $PID ]
        then
            echo
            echo "Already started. PID: [$( cat $PID )]"
        else
            touch $PID
            #eval command for avoid conflicts with "" in the command line parameters
            if (nohup `eval  $COMMAND`) >>$LOG 2>&1 &
            then echo $! >$PID
                 echo "Done."
                 echo "$(date '+%Y-%m-%d %X'): START" >>$LOG
            else echo "Error... "
                 /bin/rm $PID
            fi
        fi
    }
    
    stop() {
        if [ -f $PID ]
        then
            if kill -- -$(ps -o pgid= $(cat $PID) | grep -o [0-9]*)
            then echo "Done."
                 echo "$(date '+%Y-%m-%d %X'): STOP" >>$LOG
            fi
            /bin/rm $PID
        else
            echo "No pid file. Already stopped?"
        fi
    }
    
    case "$1" in
        'start')
                start
                ;;
        'stop')
                stop
                ;;
        'restart')
                stop ; echo "Sleeping..."; sleep 1 ;
                start
                ;;
        'status')
                status
                ;;
        *)
                echo
                echo "Usage: $0 { start [#port] | stop | restart [#port] | status }"
                echo
                exit 1
                ;;
    esac
    
    exit 0
    
    Sign up for free
  • 相关阅读:
    MySQL企业常用集群图解
    MySQL常见错误类型
    MySQL 数据库增量数据恢复案例
    异地备份同步校验脚本
    python 自动化之路 day 面向对象基础
    Docker 入门
    awk知识点总结
    Linux文件管理类命令及命令别名
    Linux重定向
    Linux进程管理
  • 原文地址:https://www.cnblogs.com/z1500592/p/6517883.html
Copyright © 2011-2022 走看看