本文主要是介绍多个jar包先后启动脚本,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.创建Server.sh
export DC_UPMS_BIZ=dc-upms-biz.jar
export DC_GATEWAY=dc-gateway.jar
export DC_AUTH=dc-auth.jar#qualificationexport UPMS_BIZ_port=4000
export GATEWAY_port=9999
export AUTH_port=3000case "$1" instart)## 启动upms-bizecho "--------开始启动UPMS_BIZ---------------"nohup java -jar $DC_UPMS_BIZ > /data/wwwroot/diseaseControl/logs/dc-upms-biz/log.log &UPMS_BIZ_pid=`lsof -i:$UPMS-BIZ_port|grep "LISTEN"|awk '{print $2}'`until [ -n "$UPMS_BIZ_pid" ]doUPMS_BIZ_pid=`lsof -i:$UPMS_BIZ_port|grep "LISTEN"|awk '{print $2}'` doneecho "UPMS_BIZ pid is $UPMS_BIZ_pid" echo "---------UPMS-BIZ 启动成功-----------"## 启动authecho "--------开始启动AUTH---------------"nohup java -jar $DC_AUTH > /data/wwwroot/diseaseControl/logs/dc-auth/log.log &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}'` doneecho "AUTH pid is $AUTH_pid" echo "---------AUTH 启动成功-----------"## 启动GATEWAYecho "--------开始启动USER---------------"nohup java -jar $DC_GATEWAY > /data/wwwroot/diseaseControl/logs/dc-gateway/log.log &GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$USER_pid" ]doUSER_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 $DC_UPMS_BIZ | grep -v "grep" | awk '{print $2}'`if [ "$P_ID" == "" ]; thenecho "===UPMS_BIZ process not exists or stop success"elsekill -9 $P_IDecho "UPMS_BIZ killed success"fiP_ID=`ps -ef | grep -w $DC_GATEWAY | grep -v "grep" | awk '{print $2}'`if [ "$P_ID" == "" ]; thenecho "===DC_GATEWAY process not exists or stop success"elsekill -9 $P_IDecho "DC_GATEWAY killed success"fiP_ID=`ps -ef | grep -w $DC_AUTH | grep -v "grep" | awk '{print $2}'`if [ "$P_ID" == "" ]; thenecho "===DC_AUTH process not exists or stop success"elsekill -9 $P_IDecho "DC_AUTH killed success"fiecho "===stop success===";; restart)$0 stopsleep 2$0 startecho "===restart success===";;
esac
exit 0
- 启动方式jar包上一级目录执行./server.sh start进行启动
./server.sh stop 停止 ./server.sh restart 重启
这篇关于多个jar包先后启动脚本的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!