zoukankan      html  css  js  c++  java
  • ~随笔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
    

      

  • 相关阅读:
    Elasticsearch之优化
    前端页面加载速度优化---Ngnix之GZIP压缩
    Nginx的try_files使用详解
    elk6.3.2在线安装中文分词工具IK
    filebeat5与filebeat6配置index的差异
    十分钟部署Anemometer作为Mysql慢查询可视化系统
    虚拟机磁盘逻辑卷扩容
    十分钟搭建和使用ELK日志分析系统
    关于NODEJS性能测试和优缺点总结
    十分钟搭建和使用sonarqube代码质量管理平台
  • 原文地址:https://www.cnblogs.com/gaojl/p/11528513.html
Copyright © 2011-2022 走看看