• ~随笔B024~Sequential execution of jar packages through shell scripts under Linux


    #!/bin/bash
    export EUREKA=cloud-basics-eureka-1.0.0-RELEASE.jar
    export LOGIN=cloud-new-ms-user-login-1.0.0-SNAPSHOT.jar
    export UC=cloud-new-ms-user-center-provider-1.0.0-SNAPSHOT.jar
    export EDCBG=cloud-new-ms-edc-bg-provider-0.0.1-SNAPSHOT.jar
    export EDCPF=cloud-new-ms-edc-pf-provider-0.0.1-SNAPSHOT.jar
    export GATEWAY=cloud-new-gateway-1.0.0-SNAPSHOT.jar
     
    
    export EUREKA_port=8761
    export LOGIN_port=8080
    export UC_port=9060
    export EDCBG_port=9073
    export EDCPF_port=9083
    export GATEWAY_port=8088
    
    export properties=dis
    export log=/new_webapp/edcLog
    
    case "$1" in
     
    start)
            ## 启动eureka
            echo "--------eureka 开始启动--------------"
            nohup java -jar $EUREKA >>$log 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 启动成功--------------"
    		
    		## 启动 LOGIN
            echo "--------LOGIN 开始启动---------------"
            nohup java -jar -Dspring.profiles.active=$properties $LOGIN >>$log 2>&1 &
            LOGIN_pid=`lsof -i:$LOGIN_port|grep "LISTEN"|awk '{print $2}'` 
            until [ -n "$LOGIN_pid" ]
                do
                  LOGIN_pid=`lsof -i:$LOGIN_port|grep "LISTEN"|awk '{print $2}'`  
                done
            echo "LOGIN pid is $LOGIN_pid"     
            echo "---------LOGIN 启动成功-----------"
    		
    		## 启动 UC
            echo "--------UC 开始启动---------------"
            nohup java -jar -Dspring.profiles.active=$properties $UC >>$log 2>&1 &
            UC_pid=`lsof -i:$UC_port|grep "LISTEN"|awk '{print $2}'` 
            until [ -n "$UC_pid" ]
                do
                  UC_pid=`lsof -i:$UC_port|grep "LISTEN"|awk '{print $2}'`  
                done
            echo "UC pid is $UC_pid"     
            echo "---------UC 启动成功-----------"
    		
    		## 启动 EDCBG
            echo "--------EDCBG 开始启动---------------"
            nohup java -jar -Dspring.profiles.active=$properties $EDCBG >>$log 2>&1 &
            EDCBG_pid=`lsof -i:$EDCBG_port|grep "LISTEN"|awk '{print $2}'` 
            until [ -n "$EDCBG_pid" ]
                do
                  EDCBG_pid=`lsof -i:$EDCBG_port|grep "LISTEN"|awk '{print $2}'`  
                done
            echo "EDCBG pid is $EDCBG_pid"     
            echo "---------EDCBG 启动成功-----------"
    		
            ## 启动 EDCPF
            echo "--------EDCPF 开始启动---------------"
            nohup java -jar -Dspring.profiles.active=$properties $EDCPF >>$log 2>&1 &
            EDCPF_pid=`lsof -i:$EDCPF_port|grep "LISTEN"|awk '{print $2}'` 
            until [ -n "$EDCPF_pid" ]
                do
                  EDCPF_pid=`lsof -i:$EDCPF_port|grep "LISTEN"|awk '{print $2}'`  
                done
            echo "EDCPF pid is $EDCPF_pid"     
            echo "---------EDCPF 启动成功-----------"
    		
    		 ## 启动 GATEWAY
            echo "--------GATEWAY 开始启动---------------"
            nohup java -jar -Dspring.profiles.active=dev $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 启动成功-----------"
     
           
            
            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 $LOGIN | grep -v "grep" | awk '{print $2}'`
            if [ "$P_ID" == "" ]; then
                echo "===LOGIN process not exists or stop success"
            else
                kill -9 $P_ID
                echo "LOGIN killed success"
            fi
    		P_ID=`ps -ef | grep -w $UC | grep -v "grep" | awk '{print $2}'`
            if [ "$P_ID" == "" ]; then
                echo "===UC process not exists or stop success"
            else
                kill -9 $P_ID
                echo "UC killed success"
            fi
    		P_ID=`ps -ef | grep -w $EDCBG | grep -v "grep" | awk '{print $2}'`
            if [ "$P_ID" == "" ]; then
                echo "===EDCBG process not exists or stop success"
            else
                kill -9 $P_ID
                echo "EDCBG killed success"
    		fi
    		P_ID=`ps -ef | grep -w $EDCPF | grep -v "grep" | awk '{print $2}'`
            if [ "$P_ID" == "" ]; then
                echo "===EDCPF process not exists or stop success"
            else
                kill -9 $P_ID
                echo "EDCPF 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
     
            echo "===stop success==="
            ;;   
    restart)
            $0 stop
            sleep 2
            $0 start
            echo "===restart success==="
            ;;  
    		
    esac	
    exit 0
    

      

  • 相关阅读:
    如何:创建自定义 HTTP 模块
    [转]开源邮件系统
    [转]开源.NET邮件服务器
    [转]文件上传及图片水印
    oracle存储过程学习收集|韩顺平oracle视频教程|
    PLSQL自动输入select * from|附件在cnblogs文件|
    oracle有规律数据触发器实现递增(NC地区分类)|更新一路case简化|
    oracle中的几种循环|转|
    官方解释sqlplus /nolog conn /as sysdba无密码可登陆
    建工项目对账查询引擎sql
  • 原文地址:https://www.cnblogs.com/gaojl/p/11528513.html
Copyright © 2020-2023  润新知