Linux下按顺序批量启动jar

14 篇文章 0 订阅

#!/bin/sh
export EUREKA=eurekaserver.jar
export CONFIG=configserver.jar
export GATEWAY=zuulgatewayserver.jar
export AUTH=authorizeserver.jar
export LOG=logstatisticsserver.jar
export APPMGR=appmgrserver.jar
export ORGANIZEUSER=organizeuserserver.jar
export JTMOP=jtmopserver.jar

export EUREKA_log=…/logs/eurekaserver.log
export CONFIG_log=…/logs/configserver.log
export GATEWAY_log=…/logs/zuulgatewayserver.log
export AUTH_log=…/logs/authorizeserver.log
export LOG_log=…/logs/logstatisticsserver.log
export APPMGR_log=…/logs/appmgrserver.log
export ORGANIZEUSER_log=…/logs/organizeuserserver.log
export JTMOP_log=…/logs/jtmopserver.log

export EUREKA_port=10080
export CONFIG_port=10085
export GATEWAY_port=10084
export AUTH_port=10088
export LOG_port=10093
export APPMGR_port=10092
export ORGANIZEUSER_port=10087
export JTMOP_port=10091

case “$1” in

start)
## 启动eureka
echo “--------eureka 开始启动--------------”
nohup java -jar $EUREKA > KaTeX parse error: Expected 'EOF', got '&' at position 14: EUREKA_log 2>&̲1 & EUR…EUREKA_port|grep “LISTEN”|awk '{print KaTeX parse error: Expected 'EOF', got '}' at position 2: 2}̲'` unti…EUREKA_pid" ]
do
EUREKA_pid=lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'
done
echo “EUREKA pid is $EUREKA_pid”
sleep 10
echo “--------eureka 启动成功--------------”

    ## 启动config
    echo "--------开始启动CONFIG---------------"
    nohup java -jar $CONFIG > $CONFIG_log 2>&1 &
    CONFIG_pid=`lsof -i:$CONFIG_port|grep "LISTEN"|awk '{print $2}'` 
    until [ -n "$CONFIG_pid" ]
        do
          CONFIG_pid=`lsof -i:$CONFIG_port|grep "LISTEN"|awk '{print $2}'`  
        done
    echo "CONFIG pid is $CONFIG_pid"
    sleep 30
    echo "---------CONFIG 启动成功-----------"

    ## 启动gateway
    echo "--------开始启动GATEWAY---------------"
    nohup java -jar $GATEWAY > $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 启动成功-----------"

    ## 启动auth
    echo "--------开始启动AUTH---------------"
    nohup java -jar $AUTH > $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 启动成功-----------"
             
    ## 启动log
    echo "--------开始启动LOG---------------"
    nohup java -jar $LOG > $LOG_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 启动成功-----------"
    
    ## 启动appmgr
    echo "--------开始启动APPMGR---------------"
    nohup java -jar $APPMGR > $APPMGR_log 2>&1 &
    APPMGR_pid=`lsof -i:$APPMGR_port|grep "LISTEN"|awk '{print $2}'`
    until [ -n "$APPMGR_pid" ]
        do
          APPMGR_pid=`lsof -i:$APPMGR_port|grep "LISTEN"|awk '{print $2}'`  
        done
    echo "APPMGR pid is $APPMGR_pid"     
    echo "---------APPMGR 启动成功-----------"
    
    ## 启动organizeuser
    echo "--------开始启动ORGANIZEUSER---------------"
    nohup java -jar $ORGANIZEUSER > $ORGANIZEUSER_log 2>&1 &
    ORGANIZEUSER_pid=`lsof -i:$ORGANIZEUSER_port|grep "LISTEN"|awk '{print $2}'`
    until [ -n "$ORGANIZEUSER_pid" ]
        do
          ORGANIZEUSER_pid=`lsof -i:$ORGANIZEUSER_port|grep "LISTEN"|awk '{print $2}'`  
        done
    echo "ORGANIZEUSER pid is $ORGANIZEUSER_pid"     
    echo "---------ORGANIZEUSER 启动成功-----------"
    
    ## 启动jtmop
    echo "--------开始启动JTMOP---------------"
    nohup java -jar $JTMOP > $JTMOP_log 2>&1 &
    JTMOP_pid=`lsof -i:$JTMOP_port|grep "LISTEN"|awk '{print $2}'`
    until [ -n "$JTMOP_pid" ]
        do
          JTMOP_pid=`lsof -i:$JTMOP_port|grep "LISTEN"|awk '{print $2}'`  
        done
    echo "JTMOP pid is $JTMOP_pid"     
    echo "---------JTMOP 启动成功-----------"
    
    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 $CONFIG | grep -v "grep" | awk '{print $2}'`
    if [ "$P_ID" == "" ]; then
        echo "===CONFIG process not exists or stop success"
    else
        kill -9 $P_ID
        echo "CONFIG 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 $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 $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 $APPMGR | grep -v "grep" | awk '{print $2}'`
    if [ "$P_ID" == "" ]; then
        echo "===APPMGR process not exists or stop success"
    else
        kill -9 $P_ID
        echo "APPMGR killed success"
    fi
    
     P_ID=`ps -ef | grep -w $ORGANIZEUSER | grep -v "grep" | awk '{print $2}'`
    if [ "$P_ID" == "" ]; then
        echo "===ORGANIZEUSER process not exists or stop success"
    else
        kill -9 $P_ID
        echo "ORGANIZEUSER killed success"
    fi
    
     P_ID=`ps -ef | grep -w $JTMOP | grep -v "grep" | awk '{print $2}'`
    if [ "$P_ID" == "" ]; then
        echo "===JTMOP process not exists or stop success"
    else
        kill -9 $P_ID
        echo "JTMOP killed success"
    fi

    echo "===stop success==="
    ;;   

restart)
$0 stop
sleep 10
$0 start
echo “=restart success=”
;;
esac
exit 0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值