#!/bin/sh
pp=/root/target
export REGISTER=$pp/pigx-register.jar
export AUTH=$pp/pigx-auth.jar
export ADMIN=$pp/pigx-upms-biz.jar
export ASSET=$pp/pigx-asset-biz.jar
export XXLJOB=$pp/pigx-xxl-job-admin.jar
export ELECTRIC=$pp/pigx-electric-biz.jar
export GATEWAY=$pp/pigx-gateway.jar
?
export REGISTER_port=8848
export AUTH_port=3000
export ADMIN_port=4000
export ASSET_port=6060
export GATEWAY_port=9999
export XXLJOB_port=9080
export ELECTRIC_port=6637
?
case "$1" in
?
start)
? ? ? ? ## 启动register
? ? ? ? echo "REGISTER开始启动----------------------"
? ? ? ? nohup java -jar $REGISTER 1>>./register.log 2>&1 &
? ? ? ? REGISTER_pid=`lsof -i:$REGISTER_port|grep "LISTEN"|awk '{print $2}'`
? ? ? ? until [ -n "$REGISTER_pid" ]
? ? ? ? ? ? do
? ? ? ? ? ? ? REGISTER_pid=`lsof -i:$REGISTER_port|grep "LISTEN"|awk '{print $2}'` ?
? ? ? ? ? ? done
? ? ? ? echo "----------------------REGISTER启动成功pid:$REGISTER_pid"
?? ??? ?
?? ? echo "AUTH开始启动----------------------"
? ? ? ? nohup java -jar $AUTH 1>>./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:$AUTH_pid"
?? ?
? ? ? ? echo "ADMIN开始启动----------------------"
? ? ? ? nohup java -jar $ADMIN 1>>./ADMIN.log 2>&1 &
? ? ? ? ADMIN_pid=`lsof -i:$ADMIN_port|grep "LISTEN"|awk '{print $2}'`
? ? ? ? until [ -n "$ADMIN_pid" ]
? ? ? ? ? ? do
? ? ? ? ? ? ? ADMIN_pid=`lsof -i:$ADMIN_port|grep "LISTEN"|awk '{print $2}'` ?
? ? ? ? ? ? done
? ? ? ? echo "----------------------ADMIN启动成功pid:$ADMIN_pid"
? ? ? ? ? ? ? ? echo "ASSET开始启动----------------------"
? ? ? ? nohup java -jar $ASSET 1>>./ASSET.log 2>&1 &
? ? ? ? ASSET_pid=`lsof -i:$ASSET_port|grep "LISTEN"|awk '{print $2}'`
? ? ? ? until [ -n "$ASSET_pid" ]
? ? ? ? ? ? do
? ? ? ? ? ? ? ASSET_pid=`lsof -i:$ASSET_port|grep "LISTEN"|awk '{print $2}'` ?
? ? ? ? ? ? done
? ? ? ? echo "----------------------ASSET启动成功pid:$ASSET_pid"
?? ? ? ? ? ?echo "GATEWAY开始启动----------------------"
? ? ? ? nohup java -jar $GATEWAY 1>>./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:$GATEWAY_pid"
?? ? ? ? ? ?echo "XXLJOB开始启动----------------------"
? ? ? ? nohup java -jar $XXLJOB 1>>./XXLJOB.log 2>&1 &
? ? ? ? XXLJOB_pid=`lsof -i:$XXLJOB_port|grep "LISTEN"|awk '{print $2}'`
? ? ? ? until [ -n "$XXLJOB_pid" ]
? ? ? ? ? ? do
? ? ? ? ? ? ? XXLJOB_pid=`lsof -i:$XXLJOB_port|grep "LISTEN"|awk '{print $2}'` ?
? ? ? ? ? ? done
? ? ? ? echo "----------------------XXLJOB启动成功pid:$XXLJOB_pid"
?? ?## 启动ELECTRIC
? ? ? ? echo "ELECTRIC开始启动----------------------"
? ? ? ? nohup java -jar $ELECTRIC 1>>./ELECTRIC.log 2>&1 &
? ? ? ? ELECTRIC_pid=`lsof -i:$ELECTRIC_port|grep "LISTEN"|awk '{print $2}'`
? ? ? ? until [ -n "$ELECTRIC_pid" ]
? ? ? ? ? ? do
? ? ? ? ? ? ? ELECTRIC_pid=`lsof -i:$ELECTRIC_port|grep "LISTEN"|awk '{print $2}'` ?
? ? ? ? ? ? done
? ? ? ? echo "----------------------ELECTRIC启动成功pid:$ELECTRIC_pid"
?? ?;;
?
?stop)
?? ?
?? ?echo "$ELECTRIC"
? ? ? ? P_ID=`ps -ef | grep -w $REGISTER | grep -v "grep" | awk '{print $2}'`
? ? ? ? if [ "$P_ID" == "" ]; then
? ? ? ? ? ? echo "===REGISTER process not exists or stop success"
? ? ? ? else
? ? ? ? ? ? kill -9 $P_ID
? ? ? ? ? ? echo "REGISTER 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 $ADMIN | grep -v "grep" | awk '{print $2}'`
? ? ? ? if [ "$P_ID" == "" ]; then
? ? ? ? ? ? echo "===ADMIN process not exists or stop success"
? ? ? ? else
? ? ? ? ? ? kill -9 $P_ID
? ? ? ? ? ? echo "ADMIN killed success"
? ? ? ? fi
?? ?P_ID=`ps -ef | grep -w $ASSET | grep -v "grep" | awk '{print $2}'`
? ? ? ? if [ "$P_ID" == "" ]; then
? ? ? ? ? ? echo "===ASSET process not exists or stop success"
? ? ? ? else
? ? ? ? ? ? kill -9 $P_ID
? ? ? ? ? ? echo "ASSET killed success"
? ? ? ? fi
?? ?P_ID=`ps -ef | grep -w $XXLJOB | grep -v "grep" | awk '{print $2}'`
? ? ? ? if [ "$P_ID" == "" ]; then
? ? ? ? ? ? echo "===XXLJOB process not exists or stop success"
? ? ? ? else
? ? ? ? ? ? kill -9 $P_ID
? ? ? ? ? ? echo "XXLJOB 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 $ELECTRIC | grep -v "grep" | awk '{print $2}'`
? ? ? ? if [ "$P_ID" == "" ]; then
? ? ? ? ? ? echo "===ELECTRIC process not exists or stop success"
? ? ? ? else
? ? ? ? ? ? kill -9 $P_ID
? ? ? ? ? ? echo "ELECTRIC killed success"
? ? ? ? fi
?
? ? ? ? echo "===stop success==="
? ? ? ? ;; ??
?
restart)
? ? ? ? $0 stop
? ? ? ? sleep 2
? ? ? ? $0 start
? ? ? ? echo "===restart success==="
? ? ? ? ;; ??
esac?? ?
exit 0
启动命令
vim server.sh --复制以上内容
chmod 777 server.sh? --赋予可执行权限
./server.sh start | stop | restart
|