#!/bin/sh
export EUREKA=pigx-eureka.jar
export CONFIG=pigx-config.jar
export GATEWAY=pigx-gateway.jar
export AUTH=pigx-auth.jar
export UPMS=pigx-upms-biz.jar
export EUREKA_port=8761export CONFIG_port=8888export GATEWAY_port=9999export AUTH_port=3000export UPMS_port=4000
case "$1" instart)
## 启动eureka
echo"--------eureka 开始启动--------------"nohup java-jar $EUREKA &EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`
until [-n "$EUREKA_pid"]doEUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`
done
echo"EUREKA pid is $EUREKA_pid"echo"--------eureka 启动成功--------------"## 启动config
echo"--------开始启动CONFIG---------------"nohup java-jar $CONFIG &CONFIG_pid=`lsof -i:$CONFIG_port|grep "LISTEN"|awk '{print $2}'`
until [-n "$CONFIG_pid"]doCONFIG_pid=`lsof -i:$CONFIG_port|grep "LISTEN"|awk '{print $2}'`
done
echo"CONFIG pid is $CONFIG_pid"sleep 10
echo"---------CONFIG 启动成功-----------"## 启动gateway
echo"--------开始启动GATEWAY---------------"nohup java-jar $GATEWAY &GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`
until [-n "$GATEWAY_pid"]doGATEWAY_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_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`
until [-n "$AUTH_pid"]doAUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`
done
echo"AUTH pid is $AUTH_pid"echo"---------AUTH 启动成功-----------"## 启动upms
echo"--------开始启动UPMS---------------"nohup java-jar $UPMS &UPMS_pid=`lsof -i:$UPMS_port|grep "LISTEN"|awk '{print $2}'`
until [-n "$UPMS_pid"]doUPMS_pid=`lsof -i:$UPMS_port|grep "LISTEN"|awk '{print $2}'`
done
echo"UPMS pid is $UPMS_pid"echo"---------UPMS 启动成功-----------"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"
elsekill-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"
elsekill-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"
elsekill-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"
elsekill-9$P_ID
echo"AUTH killed success"fi
P_ID=`ps -ef | grep -w $UPMS | grep -v "grep" | awk '{print $2}'`if [ "$P_ID" == ""]; then
echo"===UPMS process not exists or stop success"
elsekill-9$P_ID
echo"UPMS killed success"fi
echo"===stop success===";;
restart)
$0stop
sleep2$0start
echo"===restart success===";;
esac
exit0