这里使用shell脚本,按照我下面的稍微修改一下举行了
#!/bin/sh
export EUREKA=medicine-registry-1.0-SNAPSHOT.jar
export USER=medicine-user-service-1.0-SNAPSHOT.jar
export GATEWAY=medicine-gateway-1.0-SNAPSHOT.jar
export AUTH=medicine-auth-service-1.0-SNAPSHOT.jar
export COMMON=medicine-common-service-1.0-SNAPSHOT.jar
export ORDER=medicine-order-service-1.0-SNAPSHOT.jar
export TASK=medicine-task-service-1.0-SNAPSHOT.jar
export UPLOAD=medicine-upload-1.0-SNAPSHOT.jar
export PRODUCT=medicine-product-service-1.0-SNAPSHOT.jar
export QUALIFICATION=medicine-qualification-service-1.0-SNAPSHOT.jar
export SMS=medicine-sms-1.0-SNAPSHOT.jar
#qualification
export EUREKA_port=10086
export USER_port=8005
export GATEWAY_port=10010
export AUTH_port=8007
export COMMON_port=8084
export ORDER_port=8081
export TASK_port=8088
export UPLOAD_port=8002
export PRODUCT_port=8083
export QUALIFICATION_port=8006
export SMS_port=8009
case "$1" in
start)
## 启动eureka
echo "--------eureka 开始启动--------------"
nohup java -Xms256m -Xmx512m -jar $EUREKA >/www/wwwroot/medicine/log/eureka.out &
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 启动成功--------------"
## 启动gateway
echo "--------开始启动GATEWAY---------------"
nohup java -Xms256m -Xmx512m -jar $GATEWAY >/www/wwwroot/medicine/log/gateway.out &
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 -Xms256m -Xmx512m -jar $AUTH >/www/wwwroot/medicine/log/auth.out &
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
sleep 10
echo "AUTH pid is $AUTH_pid"
echo "---------AUTH 启动成功-----------"
## 启动USER
echo "--------开始启动USER---------------"
nohup java -Xms512m -Xmx1024m -jar $USER >/www/wwwroot/medicine/log/user.out &
USER_pid=`lsof -i:$USER_port|grep "LISTEN"|awk '{print $2}'`
# until [ -n "$USER_pid" ]
# do
# USER_pid=`lsof -i:$USER_port|grep "LISTEN"|awk '{print $2}'`
# done
sleep 10
echo "USER pid is $USER_pid"
echo "---------USER 启动成功-----------"
## 启动common
echo "--------common 开始启动--------------"
nohup java -Xms256m -Xmx512m -jar $COMMON >/www/wwwroot/medicine/log/common.out &
COMMON_pid=`lsof -i:$COMMON_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$EUREKA_pid" ]
do
COMMON_pid=`lsof -i:$COMMON_port|grep "LISTEN"|awk '{print $2}'`
done
echo "COMMON pid is $COMMON_pid"
echo "--------common 启动成功--------------"
## 启动order
echo "--------开始启动order---------------"
nohup java -Xms512m -Xmx1024m -jar $ORDER >/www/wwwroot/medicine/log/order.out &
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 启动成功-----------"
## 启动task
echo "--------开始启动TASK---------------"
nohup java -Xms512m -Xmx1024m -jar $TASK >/www/wwwroot/medicine/log/task.out &
TASK_pid=`lsof -i:$TASK_port|grep "LISTEN"|awk '{print $2}'`
# until [ -n "$AUTH_pid" ]
# do
# AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`
# done
sleep 10
echo "TASK pid is $TASK_pid"
echo "---------TASK 启动成功-----------"
## 启动UPLOAD
echo "--------开始启动UPLOAD---------------"
nohup java -Xms256m -Xmx512m -jar $UPLOAD >/www/wwwroot/medicine/log/upload.out &
UPLOAD_pid=`lsof -i:$UPLOAD_port|grep "LISTEN"|awk '{print $2}'`
# until [ -n "$USER_pid" ]
# do
# USER_pid=`lsof -i:$USER_port|grep "LISTEN"|awk '{print $2}'`
# done
sleep 10
echo "USER pid is $UPLOAD_pid"
echo "---------UPLOAD 启动成功-----------"
## 启动PRODUCT
echo "--------开始启动PRODUCT---------------"
nohup java -Xms256m -Xmx512m -jar $PRODUCT >/www/wwwroot/medicine/log/product.out &
PRODUCT_pid=`lsof -i:$PRODUCT_port|grep "LISTEN"|awk '{print $2}'`
# until [ -n "$USER_pid" ]
# do
# USER_pid=`lsof -i:$USER_port|grep "LISTEN"|awk '{print $2}'`
# done
sleep 10
echo "PRODUCT pid is $PRODUCT_pid"
echo "---------PRODUCT 启动成功-----------"
## 启动qualification
echo "--------开始启动QUALIFICATION---------------"
nohup java -Xms256m -Xmx512m -jar $QUALIFICATION >/www/wwwroot/medicine/log/qualification.out &
QUALIFICATION_pid=`lsof -i:$QUALIFICATION_port|grep "LISTEN"|awk '{print $2}'`
# until [ -n "$USER_pid" ]
# do
# USER_pid=`lsof -i:$USER_port|grep "LISTEN"|awk '{print $2}'`
# done
sleep 10
echo "QUALIFICATION pid is $QUALIFICATION_pid"
echo "---------QUALIFICATION 启动成功-----------"
## 启动sms
echo "--------开始启动QUALIFICATION---------------"
nohup java -Xms256m -Xmx512m -jar $SMS >/www/wwwroot/medicine/log/sms.out &
SMS_pid=`lsof -i:$SMS_port|grep "LISTEN"|awk '{print $2}'`
# until [ -n "$USER_pid" ]
# do
# USER_pid=`lsof -i:$USER_port|grep "LISTEN"|awk '{print $2}'`
# done
sleep 10
echo "SMS pid is $SMS_pid"
echo "---------SMS 启动成功-----------"
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 $USER | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===USER process not exists or stop success"
else
kill -9 $P_ID
echo "USER 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 $COMMON | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===COMMON process not exists or stop success"
else
kill -9 $P_ID
echo "COMMON 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 $TASK | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===TASK process not exists or stop success"
else
kill -9 $P_ID
echo "TASK killed success"
fi
P_ID=`ps -ef | grep -w $UPLOAD | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===UPLOAD process not exists or stop success"
else
kill -9 $P_ID
echo "UPLOAD killed success"
fi
P_ID=`ps -ef | grep -w $PRODUCT | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===PRODUCT process not exists or stop success"
else
kill -9 $P_ID
echo "PRODUCT killed success"
fi
P_ID=`ps -ef | grep -w $QUALIFICATION | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===QUALIFICATION process not exists or stop success"
else
kill -9 $P_ID
echo "QUALIFICATION killed success"
fi
P_ID=`ps -ef | grep -w $SMS | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===SMS process not exists or stop success"
else
kill -9 $P_ID
echo "SMS killed success"
fi
echo "===stop success==="
;;
restart)
$0 stop
sleep 2
$0 start
echo "===restart success==="
;;
esac
exit 0