shell一键启动脚本

#!/bin/sh
export EUREKA=eureka.jar
export ADMINAUTH=admin-auth-0.0.1.jar
export ADMINCONFIG=admin-config-0.0.1.jar
export ADVICE=hospital-advice.jar
export AUTH=hospital-auth.jar
export DATA=hospital-data.jar
export GATEWAY=hospital-gateway.jar
export INFORM=hospital-inform.jar
export INTELLIGENTDIAGNOSIS=hospital-intelligentDiagnosis-1.0.jar
export INTERACTIVE=hospital-interactive-1.0-SNAPSHOT.jar
export MESSAGE=hospital-message-1.0.jar
export NEWS=hospital-news-2.0.4.RELEASE.jar
export ORDER=hospital-order.jar
export SUBSCRIBE=hospital-subscribe-0.0.1-SNAPSHOT.jar
export LOG=hospital-LOG-0.0.1-SNAPSHOT.jar

export WEBPATIENT=hospital-web-patient-1.0.jar
export ONLIONDIAGNOSIS=MESSAGE-server-0.0.1-SNAPSHOT.jar 
export UIDOCTOR=MESSAGE-server-0.0.1-SNAPSHOT.jar 
export CHATROOM=AUTH-server-0.0.1-SNAPSHOT.jar

export EUREKA_port=8761
export ADMINAUTH_port=7053
export ADMINCONFIG_port=7054
export ADVICE_port=7007
export AUTH_port=7050
export DATA_port=7011
export GATEWAY_port=7052
export INFORM_port=7002
export INTELLIGENTDIAGNOSIS_port=7004
export INTERACTIVE_port=7010
export MESSAGE_port=7015
export NEWS_port=7009
export ORDER_port=7012
export SUBSCRIBE_port=7003
export LOG_port=7060

export CHATROOM_port=AUTH-server-0.0.1-SNAPSHOT.jar
export ONLIONDIAGNOSIS_port=MESSAGE-server-0.0.1-SNAPSHOT.jar 
export WEBPATIENT_port=MESSAGE-server-0.0.1-SNAPSHOT.jar 
export UIDOCTOR_port=MESSAGE-server-0.0.1-SNAPSHOT.jar 

 
case "$1" in
 
start)
    ## 启动eureka 
    EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`
    if [ ! -n "$EUREKA_pid" ]; then
        echo "--------eureka 开始启动--------------"
        nohup java -jar -Xmx512m -Xms512m $EUREKA >/dev/null 2>&1 &
        EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`
        until [ -n "$EUREKA_pid" ]
            do
              EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "EUREKA pid is $EUREKA_pid" 
        echo "--------eureka 启动成功--------------"
        fi
 
        ## 启动AUTH
        AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$AUTH_pid" ]; then
        echo "--------开始启动AUTH---------------"
        nohup java -jar $AUTH >> ./yang/mydata/logs/auth.log 2>&1 &
        AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$AUTH_pid" ]
            do
              AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "AUTH pid is $AUTH_pid"     
        echo "---------AUTH 启动成功-----------"
        fi

        ## 启动GATEWAY
        GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$GATEWAY_pid" ]; then
        echo "--------开始启动GATEWAY---------------"
        nohup java -jar $GATEWAY >>./yang/mydata/logs/gateway.log 2>&1 &
        GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$GATEWAY_pid" ]
            do
              GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "GATEWAY pid is $GATEWAY_pid"     
        echo "---------GATEWAY 启动成功-----------"
        fi

        ## 启动MESSAGE
        MESSAGE_pid=`lsof -i:$MESSAGE_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$MESSAGE_pid" ]; then
        echo "--------开始启动MESSAGE---------------"
        nohup java -jar -Xmx512m -Xms512m $MESSAGE >>./yang/mydata/logs/message.log 2>&1 &
        MESSAGE_pid=`lsof -i:$MESSAGE_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$MESSAGE_pid" ]
            do
              MESSAGE_pid=`lsof -i:$MESSAGE_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "MESSAGE pid is $MESSAGE_pid"     
        echo "---------MESSAGE 启动成功-----------"
        fi      

        ## 启动INFORM
        INFORM_pid=`lsof -i:$INFORM_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$INFORM_pid" ]; then
        echo "--------开始启动INFORM---------------"
        nohup java -jar -Xmx512m -Xms512m $INFORM >>./yang/mydata/logs/inform.log 2>&1 &
        INFORM_pid=`lsof -i:$INFORM_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$INFORM_pid" ]
            do
              INFORM_pid=`lsof -i:$INFORM_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "INFORM pid is $INFORM_pid"     
        echo "---------INFORM 启动成功-----------"
        fi

        ## 启动LOG
#       LOG_pid=`lsof -i:$LOG_port|grep "LISTEN"|awk '{print $2}'`
#       if [ ! -n "$LOG_pid" ]; then
#        echo "--------开始启动LOG---------------"
#        nohup java -jar -Xmx512m -Xms512m $LOG >>./yang/mydata/logs/loglistener.log 2>&1 &
#        LOG_pid=`lsof -i:$LOG_port|grep "LISTEN"|awk '{print $2}'` 
#        until [ -n "$LOG_pid" ]
#            do
#              LOG_pid=`lsof -i:$LOG_port|grep "LISTEN"|awk '{print $2}'`  
#            done
#        echo "LOG pid is $LOG_pid"     
#        echo "---------LOG 启动成功-----------"
#       fi
        
        
        ## 启动INTELLIGENTDIAGNOSIS
        INTELLIGENTDIAGNOSIS_pid=`lsof -i:$INTELLIGENTDIAGNOSIS_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$INTELLIGENTDIAGNOSIS_pid" ]; then
        echo "--------开始启动INTELLIGENTDIAGNOSIS---------------"
        nohup java -jar -Xmx512m -Xms512m $INTELLIGENTDIAGNOSIS >/dev/null 2>&1 &
        INTELLIGENTDIAGNOSIS_pid=`lsof -i:$INTELLIGENTDIAGNOSIS_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$INTELLIGENTDIAGNOSIS_pid" ]
            do
              INTELLIGENTDIAGNOSIS_pid=`lsof -i:$INTELLIGENTDIAGNOSIS_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "INTELLIGENTDIAGNOSIS pid is $INTELLIGENTDIAGNOSIS_pid"     
        echo "---------INTELLIGENTDIAGNOSIS 启动成功-----------"
        fi
        
        
        ## 启动INTERACTIVE
        INTERACTIVE_pid=`lsof -i:$INTERACTIVE_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$INTERACTIVE_pid" ]; then
        echo "--------开始启动INTERACTIVE---------------"
        nohup java -jar -Xmx512m -Xms512m $INTERACTIVE >>./yang/mydata/logs/interactive.log 2>&1 &
        INTERACTIVE_pid=`lsof -i:$INTERACTIVE_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$INTERACTIVE_pid" ]
            do
              INTERACTIVE_pid=`lsof -i:$INTERACTIVE_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "INTERACTIVE pid is $INTERACTIVE_pid"     
        echo "---------INTERACTIVE 启动成功-----------"
        fi
            
        ## 启动ORDER
        ORDER_pid=`lsof -i:$ORDER_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$ORDER_pid" ]; then
        echo "--------开始启动ORDER---------------"
        nohup java -jar -Xmx512m -Xms512m $ORDER >/dev/null 2>&1 &
        ORDER_pid=`lsof -i:$ORDER_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$ORDER_pid" ]
            do
              ORDER_pid=`lsof -i:$ORDER_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "ORDER pid is $ORDER_pid"     
        echo "---------ORDER 启动成功-----------"
        fi
        
        ## 启动SUBSCRIBE
        SUBSCRIBE_pid=`lsof -i:$SUBSCRIBE_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$SUBSCRIBE_pid" ]; then
        echo "--------开始启动SUBSCRIBE---------------"
        nohup java -jar -Xmx512m -Xms512m $SUBSCRIBE >/dev/null 2>&1 &
        SUBSCRIBE_pid=`lsof -i:$SUBSCRIBE_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$SUBSCRIBE_pid" ]
            do
              SUBSCRIBE_pid=`lsof -i:$SUBSCRIBE_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "SUBSCRIBE pid is $SUBSCRIBE_pid"     
        echo "---------SUBSCRIBE 启动成功-----------"
        fi  

        ## 启动ADMINAUTH
        ADMINAUTH_pid=`lsof -i:$ADMINAUTH_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$ADMINAUTH_pid" ]; then
        echo "--------开始启动ADMINAUTH---------------"
        nohup java -jar -Xmx512m -Xms512m $ADMINAUTH >/dev/null 2>&1 &
        ADMINAUTH_pid=`lsof -i:$ADMINAUTH_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$ADMINAUTH_pid" ]
            do
              ADMINAUTH_pid=`lsof -i:$ADMINAUTH_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "ADMINAUTH pid is $ADMINAUTH_pid"     
        echo "---------ADMINAUTH 启动成功-----------"
        fi
        
        ## 启动ADMINCONFIG
        ADMINCONFIG_pid=`lsof -i:$ADMINCONFIG_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$ADMINCONFIG_pid" ]; then
        echo "--------开始启动ADMINCONFIG---------------"
        nohup java -jar -Xmx512m -Xms512m $ADMINCONFIG >/dev/null 2>&1 &
        ADMINCONFIG_pid=`lsof -i:$ADMINCONFIG_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$ADMINCONFIG_pid" ]
            do
              ADMINCONFIG_pid=`lsof -i:$ADMINCONFIG_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "ADMINCONFIG pid is $ADMINCONFIG_pid"     
        echo "---------ADMINCONFIG 启动成功-----------"
        fi
        
        
        ## 启动ADVICE
        ADVICE_pid=`lsof -i:$ADVICE_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$ADVICE_pid" ]; then
        echo "--------开始启动ADVICE---------------"
        nohup java -jar -Xmx512m -Xms512m $ADVICE >/dev/null 2>&1 &
        ADVICE_pid=`lsof -i:$ADVICE_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$ADVICE_pid" ]
            do
              ADVICE_pid=`lsof -i:$ADVICE_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "ADVICE pid is $ADVICE_pid"     
        echo "---------ADVICE 启动成功-----------"
        fi
                
        ## 启动DATA
        DATA_pid=`lsof -i:$DATA_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$DATA_pid" ]; then
        echo "--------开始启动DATA---------------"
        nohup java -jar -Xmx512m -Xms512m $DATA >/dev/null 2>&1 &
        DATA_pid=`lsof -i:$DATA_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$DATA_pid" ]
            do
              DATA_pid=`lsof -i:$DATA_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "DATA pid is $DATA_pid"     
        echo "---------DATA 启动成功-----------"
        fi
        
        ## 启动NEWS
        NEWS_pid=`lsof -i:$NEWS_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$NEWS_pid" ]; then
        echo "--------开始启动NEWS---------------"
        nohup java -jar -Xmx512m -Xms512m $NEWS >/dev/null 2>&1 &
        NEWS_pid=`lsof -i:$NEWS_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$NEWS_pid" ]
            do
              NEWS_pid=`lsof -i:$NEWS_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "NEWS pid is $NEWS_pid"     
        echo "---------NEWS 启动成功-----------"
        fi

                
        echo "===startAll success==="
        ;;
 
 stop)
        P_ID=`ps -ef | grep -w $EUREKA | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===EUREKA process not exists or stop success"
        else
            kill -9 $P_ID
            echo "EUREKA killed success"
        fi
        
        P_ID=`ps -ef | grep -w $ADMINAUTH | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADMINAUTH process not exists or stop success"
        else
            kill -9 $P_ID
            echo "ADMINAUTH killed success"
        fi
        
        P_ID=`ps -ef | grep -w $ADMINCONFIG | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADMINCONFIG process not exists or stop success"
        else
            kill -9 $P_ID
            echo "ADMINCONFIG killed success"
        fi
        
        P_ID=`ps -ef | grep -w $NEWS | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===NEWS process not exists or stop success"
        else
            kill -9 $P_ID
            echo "NEWS killed success"
        fi
        
        P_ID=`ps -ef | grep -w $ADVICE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADVICE process not exists or stop success"
        else
            kill -9 $P_ID
            echo "ADVICE killed success"
        fi
        
        P_ID=`ps -ef | grep -w $AUTH | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===AUTH process not exists or stop success"
        else
            kill -9 $P_ID
            echo "AUTH killed success"
        fi
        
        P_ID=`ps -ef | grep -w $DATA | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===DATA process not exists or stop success"
        else
            kill -9 $P_ID
            echo "DATA killed success"
        fi
        
        P_ID=`ps -ef | grep -w $GATEWAY | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===GATEWAY process not exists or stop success"
        else
            kill -9 $P_ID
            echo "GATEWAY killed success"
        fi

        P_ID=`ps -ef | grep -w $LOG | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===LOG process not exists or stop success"
        else
            kill -9 $P_ID
            echo "LOG killed success"
        fi
        
        P_ID=`ps -ef | grep -w $INFORM | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INFORM process not exists or stop success"
        else
            kill -9 $P_ID
            echo "INFORM killed success"
        fi
        
        P_ID=`ps -ef | grep -w $INTELLIGENTDIAGNOSIS | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INTELLIGENTDIAGNOSIS process not exists or stop success"
        else
            kill -9 $P_ID
            echo "INTELLIGENTDIAGNOSIS killed success"
        fi
        
        P_ID=`ps -ef | grep -w $INTERACTIVE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INTERACTIVE process not exists or stop success"
        else
            kill -9 $P_ID
            echo "INTERACTIVE killed success"
        fi
        
        P_ID=`ps -ef | grep -w $MESSAGE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===MESSAGE process not exists or stop success"
        else
            kill -9 $P_ID
            echo "MESSAGE killed success"
        fi
        
        P_ID=`ps -ef | grep -w $ORDER | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ORDER process not exists or stop success"
        else
            kill -9 $P_ID
            echo "ORDER killed success"
        fi  
        
        P_ID=`ps -ef | grep -w $SUBSCRIBE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===SUBSCRIBE process not exists or stop success"
        else
            kill -9 $P_ID
            echo "SUBSCRIBE killed success"
        fi      
        
        echo "===stopAll success==="
        ;;  
        
 restart)
        $0 stop
        sleep 2
        $0 start
        echo "===restartAll success==="
        ;;   
        
 notstart)
 
        echo "notstart find bigin:"
        P_ID=`ps -ef | grep -w $EUREKA | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===EUREKA ==="
        fi
        
        P_ID=`ps -ef | grep -w $ADMINAUTH | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADMINAUTH ==="
       
        fi
        
        P_ID=`ps -ef | grep -w $ADMINCONFIG | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADMINCONFIG ==="
        
        fi
        
#       P_ID=`ps -ef | grep -w $LOG | grep -v "grep" | awk '{print $2}'`
#       if [ "$P_ID" == "" ]; then
#           echo "===LOG ==="   
#       fi

        P_ID=`ps -ef | grep -w $NEWS | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===NEWS ==="
        
        fi
        
        P_ID=`ps -ef | grep -w $ADVICE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADVICE ==="
        
        fi
        
        P_ID=`ps -ef | grep -w $AUTH | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===AUTH ==="
       
        fi
        
        P_ID=`ps -ef | grep -w $DATA | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===DATA ==="
       
        fi
        
        P_ID=`ps -ef | grep -w $GATEWAY | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===GATEWAY ==="
       
        fi
        
        P_ID=`ps -ef | grep -w $INFORM | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INFORM ==="
        
        fi
        
        P_ID=`ps -ef | grep -w $INTELLIGENTDIAGNOSIS | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INTELLIGENTDIAGNOSIS ==="
        
        fi
        
        P_ID=`ps -ef | grep -w $INTERACTIVE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INTERACTIVE ==="
        
        fi
        
        P_ID=`ps -ef | grep -w $MESSAGE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===MESSAGE ==="
        
        fi
        
        P_ID=`ps -ef | grep -w $ORDER | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ORDER ==="
        
        fi  
        
        P_ID=`ps -ef | grep -w $SUBSCRIBE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===SUBSCRIBE ==="
        
            echo "SUBSCRIBE killed success"
        fi      
        
        echo "===findAll success==="
        ;;  

EUREKA|eureka)   
        P_ID=`ps -ef | grep -w $EUREKA | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===EUREKA process not exists or stop success"
        else
            kill -9 $P_ID
            echo "EUREKA killed success"
        fi
        ## 启动eureka 
        EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$EUREKA_pid" ]; then
        echo "--------eureka 开始启动--------------"
        nohup java -jar -Xmx512m -Xms512m $EUREKA >/dev/null 2>&1 &
        EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`
        until [ -n "$EUREKA_pid" ]
            do
              EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "EUREKA pid is $EUREKA_pid" 
        echo "--------eureka 启动成功--------------"
        fi
        ;;   

 ADMINAUTH|adminauth)       
        P_ID=`ps -ef | grep -w $ADMINAUTH | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADMINAUTH process not exists or stop success"
        else
            kill -9 $P_ID
            echo "ADMINAUTH killed success"
        fi
        ## 启动ADMINAUTH
        ADMINAUTH_pid=`lsof -i:$ADMINAUTH_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$ADMINAUTH_pid" ]; then
        echo "--------开始启动ADMINAUTH---------------"
        nohup java -jar -Xmx512m -Xms512m $ADMINAUTH >/dev/null 2>&1 &
        ADMINAUTH_pid=`lsof -i:$ADMINAUTH_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$ADMINAUTH_pid" ]
            do
              ADMINAUTH_pid=`lsof -i:$ADMINAUTH_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "ADMINAUTH pid is $ADMINAUTH_pid"     
        echo "---------ADMINAUTH 启动成功-----------"
        fi      
        ;;   

 ADMINCONFIG|adminconfig)
        P_ID=`ps -ef | grep -w $ADMINCONFIG | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADMINCONFIG process not exists or stop success"
        else
            kill -9 $P_ID
            echo "ADMINCONFIG killed success"
        fi
        ## 启动ADMINCONFIG
        ADMINCONFIG_pid=`lsof -i:$ADMINCONFIG_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$ADMINCONFIG_pid" ]; then
        echo "--------开始启动ADMINCONFIG---------------"
        nohup java -jar -Xmx512m -Xms512m $ADMINCONFIG >/dev/null 2>&1 &
        ADMINCONFIG_pid=`lsof -i:$ADMINCONFIG_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$ADMINCONFIG_pid" ]
            do
              ADMINCONFIG_pid=`lsof -i:$ADMINCONFIG_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "ADMINCONFIG pid is $ADMINCONFIG_pid"     
        echo "---------ADMINCONFIG 启动成功-----------"
        fi
        ;;   
        
        
 NEWS|news) 
        P_ID=`ps -ef | grep -w $NEWS | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===NEWS process not exists or stop success"
        else
            kill -9 $P_ID
            echo "NEWS killed success"
        fi
        ## 启动NEWS
        NEWS_pid=`lsof -i:$NEWS_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$NEWS_pid" ]; then
        echo "--------开始启动NEWS---------------"
        nohup java -jar -Xmx512m -Xms512m $NEWS >/dev/null 2>&1 &
        NEWS_pid=`lsof -i:$NEWS_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$NEWS_pid" ]
            do
              NEWS_pid=`lsof -i:$NEWS_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "NEWS pid is $NEWS_pid"     
        echo "---------NEWS 启动成功-----------"
        fi
        ;;   
        
 ADVICE|advice) 
        P_ID=`ps -ef | grep -w $ADVICE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ADVICE process not exists or stop success"
        else
            kill -9 $P_ID
            echo "ADVICE killed success"
        fi
        ## 启动ADVICE
        ADVICE_pid=`lsof -i:$ADVICE_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$ADVICE_pid" ]; then
        echo "--------开始启动ADVICE---------------"
        nohup java -jar -Xmx512m -Xms512m $ADVICE >/dev/null 2>&1 &
        ADVICE_pid=`lsof -i:$ADVICE_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$ADVICE_pid" ]
            do
              ADVICE_pid=`lsof -i:$ADVICE_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "ADVICE pid is $ADVICE_pid"     
        echo "---------ADVICE 启动成功-----------"
        fi
        ;;   
        
 AUTH|auth)     
        P_ID=`ps -ef | grep -w $AUTH | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===AUTH process not exists or stop success"
        else
            kill -9 $P_ID
            echo "AUTH killed success"
        fi
        ## 启动AUTH
        AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$AUTH_pid" ]; then
        echo "--------开始启动AUTH---------------"
        nohup java -jar $AUTH >> ./yang/mydata/logs/auth.log 2>&1 &
        AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$AUTH_pid" ]
            do
              AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "AUTH pid is $AUTH_pid"     
        echo "---------AUTH 启动成功-----------"
        fi
        ;;   

 DATA|data)     
        P_ID=`ps -ef | grep -w $DATA | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===DATA process not exists or stop success"
        else
            kill -9 $P_ID
            echo "DATA killed success"
        fi
        ## 启动DATA
        DATA_pid=`lsof -i:$DATA_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$DATA_pid" ]; then
        echo "--------开始启动DATA---------------"
        nohup java -jar -Xmx512m -Xms512m $DATA >/dev/null 2>&1 &
        DATA_pid=`lsof -i:$DATA_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$DATA_pid" ]
            do
              DATA_pid=`lsof -i:$DATA_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "DATA pid is $DATA_pid"     
        echo "---------DATA 启动成功-----------"
        fi
        ;;   
        
 GATEWAY|gateway)   
        P_ID=`ps -ef | grep -w $GATEWAY | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===GATEWAY process not exists or stop success"
        else
            kill -9 $P_ID
            echo "GATEWAY killed success"
        fi
        ## 启动GATEWAY
        GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$GATEWAY_pid" ]; then
        echo "--------开始启动GATEWAY---------------"
        nohup java -jar $GATEWAY >>./yang/mydata/logs/gateway.log 2>&1 &
        GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$GATEWAY_pid" ]
            do
              GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "GATEWAY pid is $GATEWAY_pid"     
        echo "---------GATEWAY 启动成功-----------"
        fi
        ;;   
        
 INFORM|inform)     
        P_ID=`ps -ef | grep -w $INFORM | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INFORM process not exists or stop success"
        else
            kill -9 $P_ID
            echo "INFORM killed success"
        fi
        ## 启动INFORM
        INFORM_pid=`lsof -i:$INFORM_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$INFORM_pid" ]; then
        echo "--------开始启动INFORM---------------"
        nohup java -jar -Xmx512m -Xms512m $INFORM >>./yang/mydata/logs/inform.log 2>&1 &
        INFORM_pid=`lsof -i:$INFORM_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$INFORM_pid" ]
            do
              INFORM_pid=`lsof -i:$INFORM_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "INFORM pid is $INFORM_pid"     
        echo "---------INFORM 启动成功-----------"
        fi
        ;;   
        
 INTELLIGENTDIAGNOSIS|intelligentdiagnosis)     
        P_ID=`ps -ef | grep -w $INTELLIGENTDIAGNOSIS | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INTELLIGENTDIAGNOSIS process not exists or stop success"
        else
            kill -9 $P_ID
            echo "INTELLIGENTDIAGNOSIS killed success"
        fi
        ## 启动INTELLIGENTDIAGNOSIS
        INTELLIGENTDIAGNOSIS_pid=`lsof -i:$INTELLIGENTDIAGNOSIS_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$INTELLIGENTDIAGNOSIS_pid" ]; then
        echo "--------开始启动INTELLIGENTDIAGNOSIS---------------"
        nohup java -jar -Xmx512m -Xms512m $INTELLIGENTDIAGNOSIS >/dev/null 2>&1 &
        INTELLIGENTDIAGNOSIS_pid=`lsof -i:$INTELLIGENTDIAGNOSIS_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$INTELLIGENTDIAGNOSIS_pid" ]
            do
              INTELLIGENTDIAGNOSIS_pid=`lsof -i:$INTELLIGENTDIAGNOSIS_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "INTELLIGENTDIAGNOSIS pid is $INTELLIGENTDIAGNOSIS_pid"     
        echo "---------INTELLIGENTDIAGNOSIS 启动成功-----------"
        fi
        ;;   
        
 INTERACTIVE|interactive)
        P_ID=`ps -ef | grep -w $INTERACTIVE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===INTERACTIVE process not exists or stop success"
        else
            kill -9 $P_ID
            echo "INTERACTIVE killed success"
        fi
        ## 启动INTERACTIVE
        INTERACTIVE_pid=`lsof -i:$INTERACTIVE_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$INTERACTIVE_pid" ]; then
        echo "--------开始启动INTERACTIVE---------------"
        nohup java -jar -Xmx512m -Xms512m $INTERACTIVE >>./yang/mydata/logs/interactive.log 2>&1 &
        INTERACTIVE_pid=`lsof -i:$INTERACTIVE_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$INTERACTIVE_pid" ]
            do
              INTERACTIVE_pid=`lsof -i:$INTERACTIVE_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "INTERACTIVE pid is $INTERACTIVE_pid"     
        echo "---------INTERACTIVE 启动成功-----------"
        fi
        ;;   
        
 MESSAGE|message)
        P_ID=`ps -ef | grep -w $MESSAGE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===MESSAGE process not exists or stop success"
        else
            kill -9 $P_ID
            echo "MESSAGE killed success"
        fi
        ## 启动MESSAGE
        MESSAGE_pid=`lsof -i:$MESSAGE_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$MESSAGE_pid" ]; then
        echo "--------开始启动MESSAGE---------------"
        nohup java -jar -Xmx512m -Xms512m $MESSAGE >>./yang/mydata/logs/message.log 2>&1 &
        MESSAGE_pid=`lsof -i:$MESSAGE_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$MESSAGE_pid" ]
            do
              MESSAGE_pid=`lsof -i:$MESSAGE_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "MESSAGE pid is $MESSAGE_pid"     
        echo "---------MESSAGE 启动成功-----------"
        fi
        ;;   
        
 ORDER|order)       
        P_ID=`ps -ef | grep -w $ORDER | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===ORDER process not exists or stop success"
        else
            kill -9 $P_ID
            echo "ORDER killed success"
        fi  
        ## 启动ORDER
        ORDER_pid=`lsof -i:$ORDER_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$ORDER_pid" ]; then
        echo "--------开始启动ORDER---------------"
        nohup java -jar -Xmx512m -Xms512m $ORDER >/dev/null 2>&1 &
        ORDER_pid=`lsof -i:$ORDER_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$ORDER_pid" ]
            do
              ORDER_pid=`lsof -i:$ORDER_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "ORDER pid is $ORDER_pid"     
        echo "---------ORDER 启动成功-----------"
        fi
        ;;   
        
 SUBSCRIBE|subscribe) 
        P_ID=`ps -ef | grep -w $SUBSCRIBE | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===SUBSCRIBE process not exists or stop success"
        else
            kill -9 $P_ID
            echo "SUBSCRIBE killed success"
        fi      
        ## 启动SUBSCRIBE
        SUBSCRIBE_pid=`lsof -i:$SUBSCRIBE_port|grep "LISTEN"|awk '{print $2}'`
        if [ ! -n "$SUBSCRIBE_pid" ]; then
        echo "--------开始启动SUBSCRIBE---------------"
        nohup java -jar -Xmx512m -Xms512m $SUBSCRIBE >/dev/null 2>&1 &
        SUBSCRIBE_pid=`lsof -i:$SUBSCRIBE_port|grep "LISTEN"|awk '{print $2}'` 
        until [ -n "$SUBSCRIBE_pid" ]
            do
              SUBSCRIBE_pid=`lsof -i:$SUBSCRIBE_port|grep "LISTEN"|awk '{print $2}'`  
            done
        echo "SUBSCRIBE pid is $SUBSCRIBE_pid"     
        echo "---------SUBSCRIBE 启动成功-----------"
        fi  
        ;;  
        
esac    
exit 0
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 202,056评论 5 474
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,842评论 2 378
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 148,938评论 0 335
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,296评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,292评论 5 363
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,413评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,824评论 3 393
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,493评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,686评论 1 295
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,502评论 2 318
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,553评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,281评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,820评论 3 305
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,873评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,109评论 1 258
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,699评论 2 348
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,257评论 2 341

推荐阅读更多精彩内容