本文共 17302 字,大约阅读时间需要 57 分钟。
创建脚本service.sh
sh service.sh start all(或者单个服务名称)
sh service.sh stop all(或者单个服务名称)
sh service.sh restart all(或者单个服务名称)
#!/bin/sh # 微服务服务启动脚本# jsonliu# 2020-12-05export BUS=bus-server-1.0.0.jarexport ORGANIZATION=organization-1.0.0-execute.jarexport AUTHORIZATION=authorization-server-1.0.0.jarexport AUTHENTICATION=authentication-server-1.0.0.jarexport GATEWAYADMIN=gateway-admin-1.0.0.jarexport GATEWAY=gateway-web-1.0.0.jarexport LOG=log-server-1.0.0.jarexport XFILE=safe-xfile.jarexport MONITOR=admin-1.0.0.jarexport SOCKETIO=server-socketio-1.0.0.jarexport FLOWABLE=flowable.jarexport SERVICE=service-1.0.0.jarexport EQUIPMENT=equipment-1.0.0.jarexport SAFE=safe-1.0.0.jarexport ENVPRO=envpro-1.0.0.jarexport EDUCATION=education-1.0.0.jarexport QUARTZ=quartz-server-1.0.0.jarexport REPORT=report-1.0.0.jarexport BUS_port=8440export ORGANIZATION_port=8010export AUTHORIZATION_port=8442export AUTHENTICATION_port=8441export GATEWAYADMIN_port=8445export GATEWAY_port=8443export LOG_port=8449export XFILE_port=8444export MONITOR_port=8448export SOCKETIO_port=8446export FLOWABLE_port=8450 export SERVICE_port=8011 export EQUIPMENT_port=8013 export SAFE_port=8012 export ENVPRO_port=8015 export EDUCATION_port=8014 export QUARTZ_port=8447export REPORT_port=8048 # ---------------------------启动函数---------------------------------------SBUS(){ echo "--------1、BUS 开始启动--------------" nohup java -Xmx512m -Xms512m -jar $BUS >/dev/null 2>&1 & BUS_pid=`lsof -i:$BUS_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$BUS_pid" ] do BUS_pid=`lsof -i:$BUS_port|grep "LISTEN"|awk '{print $2}'` done echo "BUS pid is $BUS_pid" echo "--------1、BUS 启动成功--------------"}SORGANIZATION(){ echo "--------2、organization 开始启动--------------" nohup java -Xmx768m -Xms768m -jar $ORGANIZATION >/dev/null 2>&1 & ORGANIZATION_pid=`lsof -i:$ORGANIZATION_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$ORGANIZATION_pid" ] do ORGANIZATION_pid=`lsof -i:$ORGANIZATION_port|grep "LISTEN"|awk '{print $2}'` done echo "ORGANIZATION pid is $ORGANIZATION_pid" echo "--------2、organization 启动成功--------------"}SAUTHORIZATION(){ echo "--------3、AUTHORIZATION 开始启动--------------" nohup java -Xmx512m -Xms512m -jar $AUTHORIZATION >/dev/null 2>&1 & AUTHORIZATION_pid=`lsof -i:$AUTHORIZATION_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$AUTHORIZATION_pid" ] do AUTHORIZATION_pid=`lsof -i:$AUTHORIZATION_port|grep "LISTEN"|awk '{print $2}'` done echo "AUTHORIZATION pid is $AUTHORIZATION_pid" echo "--------3、AUTHORIZATION 启动成功--------------"}SAUTHENTICATION(){ echo "--------4、AUTHENTICATION 开始启动--------------" nohup java -Xmx768m -Xms768m -jar $AUTHENTICATION >/dev/null 2>&1 & AUTHENTICATION_pid=`lsof -i:$AUTHENTICATION_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$AUTHENTICATION_pid" ] do AUTHENTICATION_pid=`lsof -i:$AUTHENTICATION_port|grep "LISTEN"|awk '{print $2}'` done echo "AUTHENTICATION pid is $AUTHENTICATION_pid" echo "--------4、AUTHENTICATION 启动成功--------------"}SGATEWAYADMIN(){ echo "--------5、GATEWAYADMIN 开始启动--------------" nohup java -Xmx512m -Xms512m -jar $GATEWAYADMIN >/dev/null 2>&1 & GATEWAYADMIN_pid=`lsof -i:$GATEWAYADMIN_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$GATEWAYADMIN_pid" ] do GATEWAYADMIN_pid=`lsof -i:$GATEWAYADMIN_port|grep "LISTEN"|awk '{print $2}'` done echo "GATEWAYADMIN pid is $GATEWAYADMIN_pid" echo "--------5、GATEWAYADMIN 启动成功--------------"}SGATEWAY(){ echo "--------6、GATEWAY 开始启动--------------" nohup java -Xmx768m -Xms768m -jar $GATEWAY >/dev/null 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 "--------6、GATEWAY 启动成功--------------"}SLOG(){ echo "--------7、LOG 开始启动--------------" nohup java -Xmx768m -Xms768m -jar $LOG >/dev/null 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 "--------7、LOG 启动成功--------------"}SXFILE(){ echo "--------8、XFILE 开始启动--------------" nohup java -Xmx512m -Xms512m -jar $XFILE >/dev/null 2>&1 & XFILE_pid=`lsof -i:$XFILE_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$XFILE_pid" ] do XFILE_pid=`lsof -i:$XFILE_port|grep "LISTEN"|awk '{print $2}'` done echo "XFILE pid is $XFILE_pid" echo "--------8、XFILE 启动成功--------------"}SMONITOR(){ echo "--------9、MONITOR 开始启动--------------" nohup java -Xmx512m -Xms512m -jar $MONITOR >/dev/null 2>&1 & MONITOR_pid=`lsof -i:$MONITOR_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$MONITOR_pid" ] do MONITOR_pid=`lsof -i:$MONITOR_port|grep "LISTEN"|awk '{print $2}'` done echo "MONITOR pid is $MONITOR_pid" echo "--------9、MONITOR 启动成功--------------"}SSOCKETIO(){ echo "--------10、SOCKETIO 开始启动--------------" nohup java -Xmx512m -Xms512m -jar $SOCKETIO >/dev/null 2>&1 & SOCKETIO_pid=`lsof -i:$SOCKETIO_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$SOCKETIO_pid" ] do SOCKETIO_pid=`lsof -i:$SOCKETIO_port|grep "LISTEN"|awk '{print $2}'` done echo "SOCKETIO pid is $SOCKETIO_pid" echo "--------10、SOCKETIO 启动成功--------------"}SFLOWABLE(){ echo "--------11、FLOWABLE 开始启动--------------" nohup java -Xmx768m -Xms768m -jar $FLOWABLE >/dev/null 2>&1 & FLOWABLE_pid=`lsof -i:$FLOWABLE_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$FLOWABLE_pid" ] do FLOWABLE_pid=`lsof -i:$FLOWABLE_port|grep "LISTEN"|awk '{print $2}'` done echo "FLOWABLE pid is $FLOWABLE_pid" echo "--------11、FLOWABLE 启动成功--------------"}SSERVICE(){ echo "--------12、SERVICE 开始启动--------------" nohup java -Xmx768m -Xms768m -jar $SERVICE >/dev/null 2>&1 & SERVICE_pid=`lsof -i:$SERVICE_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$SERVICE_pid" ] do SERVICE_pid=`lsof -i:$SERVICE_port|grep "LISTEN"|awk '{print $2}'` done echo "SERVICE pid is $SERVICE_pid" echo "--------12、SERVICE 启动成功--------------"}SEQUIPMENT(){ echo "--------13、EQUIPMENT 开始启动--------------" nohup java -Xmx512m -Xms512m -jar $EQUIPMENT >/dev/null 2>&1 & EQUIPMENT_pid=`lsof -i:$EQUIPMENT_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$EQUIPMENT_pid" ] do EQUIPMENT_pid=`lsof -i:$EQUIPMENT_port|grep "LISTEN"|awk '{print $2}'` done echo "EQUIPMENT pid is $EQUIPMENT_pid" echo "--------13、EQUIPMENT 启动成功--------------"}SSAFE(){ echo "--------14、SAFE 开始启动--------------" nohup java -Xmx768m -Xms768m -jar $SAFE >/dev/null 2>&1 & SAFE_pid=`lsof -i:$SAFE_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$SAFE_pid" ] do SAFE_pid=`lsof -i:$SAFE_port|grep "LISTEN"|awk '{print $2}'` done echo "SAFE pid is $SAFE_pid" echo "--------14、SAFE 启动成功--------------"}SENVPRO(){ echo "--------15、ENVPRO 开始启动--------------" nohup java -Xmx512m -Xms512m -jar $ENVPRO >/dev/null 2>&1 & ENVPRO_pid=`lsof -i:$ENVPRO_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$ENVPRO_pid" ] do ENVPRO_pid=`lsof -i:$ENVPRO_port|grep "LISTEN"|awk '{print $2}'` done echo "ENVPRO pid is $ENVPRO_pid" echo "--------15、ENVPRO 启动成功--------------"}SEDUCATION(){ echo "--------16、EDUCATION 开始启动--------------" nohup java -Xmx512m -Xms512m -jar $EDUCATION >/dev/null 2>&1 & EDUCATION_pid=`lsof -i:$EDUCATION_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$EDUCATION_pid" ] do EDUCATION_pid=`lsof -i:$EDUCATION_port|grep "LISTEN"|awk '{print $2}'` done echo "EDUCATION pid is $EDUCATION_pid" echo "--------16、EDUCATION 启动成功--------------"}SQUARTZ(){ echo "--------17、QUARTZ 开始启动--------------" nohup java -Xmx512m -Xms512m -jar $QUARTZ >/dev/null 2>&1 & QUARTZ_pid=`lsof -i:$QUARTZ_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$QUARTZ_pid" ] do QUARTZ_pid=`lsof -i:$QUARTZ_port|grep "LISTEN"|awk '{print $2}'` done echo "QUARTZ pid is $QUARTZ_pid" echo "--------17、QUARTZ 启动成功--------------"}SREPORT(){ echo "--------18、REPORT 开始启动--------------" nohup java -Xmx512m -Xms512m -jar $REPORT >/dev/null 2>&1 & REPORT_pid=`lsof -i:$REPORT_port|grep "LISTEN"|awk '{print $2}'` until [ -n "$REPORT_pid" ] do REPORT_pid=`lsof -i:$REPORT_port|grep "LISTEN"|awk '{print $2}'` done echo "REPORT pid is $REPORT_pid" echo "--------18、REPORT 启动成功--------------"}# ---------------------------停止函数---------------------------------------EBUS(){ P_ID=`ps -ef | grep -w $BUS | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then echo "===BUS process not exists or stop success" else kill -9 $P_ID echo "BUS killed success" fi }EORGANIZATION(){ P_ID=`ps -ef | grep -w $ORGANIZATION | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then echo "===ORGANIZATION process not exists or stop success" else kill -9 $P_ID echo "ORGANIZATION killed success" fi}EAUTHORIZATION(){ P_ID=`ps -ef | grep -w $AUTHORIZATION | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then echo "===AUTHORIZATION process not exists or stop success" else kill -9 $P_ID echo "AUTHORIZATION killed success" fi}EAUTHENTICATION(){ P_ID=`ps -ef | grep -w $AUTHENTICATION | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then echo "===AUTHENTICATION process not exists or stop success" else kill -9 $P_ID echo "AUTHENTICATION killed success" fi}EGATEWAYADMIN(){ P_ID=`ps -ef | grep -w $GATEWAYADMIN | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then echo "===GATEWAYADMIN process not exists or stop success" else kill -9 $P_ID echo "GATEWAYADMIN killed success" fi}EGATEWAY(){ 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}ELOG(){ 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}EXFILE(){ P_ID=`ps -ef | grep -w $XFILE | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then echo "===XFILE process not exists or stop success" else kill -9 $P_ID echo "XFILE killed success" fi}EMONITOR(){ P_ID=`ps -ef | grep -w $MONITOR | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then echo "===MONITOR process not exists or stop success" else kill -9 $P_ID echo "MONITOR killed success" fi}ESOCKETIO(){ P_ID=`ps -ef | grep -w $SOCKETIO | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then echo "===SOCKETIO process not exists or stop success" else kill -9 $P_ID echo "SOCKETIO killed success" fi}EFLOWABLE(){ P_ID=`ps -ef | grep -w $FLOWABLE | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then echo "===FLOWABLE process not exists or stop success" else kill -9 $P_ID echo "FLOWABLE killed success" fi}ESERVICE(){ P_ID=`ps -ef | grep -w $SERVICE | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then echo "===SERVICE process not exists or stop success" else kill -9 $P_ID echo "SERVICE killed success" fi}EEQUIPMENT(){ P_ID=`ps -ef | grep -w $EQUIPMENT | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then echo "===EQUIPMENT process not exists or stop success" else kill -9 $P_ID echo "EQUIPMENT killed success" fi}ESAFE(){ P_ID=`ps -ef | grep -w $SAFE | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then echo "===SAFE process not exists or stop success" else kill -9 $P_ID echo "SAFE killed success" fi}EENVPRO(){ P_ID=`ps -ef | grep -w $ENVPRO | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then echo "===ENVPRO process not exists or stop success" else kill -9 $P_ID echo "ENVPRO killed success" fi}EEDUCATION(){ P_ID=`ps -ef | grep -w $EDUCATION | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then echo "===EDUCATION process not exists or stop success" else kill -9 $P_ID echo "EDUCATION killed success" fi}EQUARTZ(){ P_ID=`ps -ef | grep -w $QUARTZ | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then echo "===QUARTZ process not exists or stop success" else kill -9 $P_ID echo "QUARTZ killed success" fi}EREPORT(){ P_ID=`ps -ef | grep -w $REPORT | grep -v "grep" | awk '{print $2}'` if [ "$P_ID" == "" ]; then echo "===REPORT process not exists or stop success" else kill -9 $P_ID echo "REPORT killed success" fi}case "$1" in start) case "$2" in bus|BUS) ## 1、启动BUS SBUS ;; organization|ORGANIZATION) ## 2、启动organization SORGANIZATION ;; authorization|AUTHORIZATION) ## 3、启动AUTHORIZATION SAUTHORIZATION ;; authentication|AUTHENTICATION) ## 4、启动AUTHENTICATION SAUTHENTICATION ;; gatewayadmin|GATEWAYADMIN) ## 5、启动GATEWAYADMIN SGATEWAYADMIN ;; gateway|GATEWAY) ## 6、启动GATEWAY SGATEWAY ;; log|LOG) ## 7、启动LOG SLOG ;; xfile|XFILE) ## 8、启动XFILE SXFILE ;; monitor|MONITOR) ## 9、启动MONITOR SMONITOR ;; socketio|SOCKETIO) ## 10、启动SOCKETIO SSOCKETIO ;; flowable|FLOWABLE) ## 11、启动FLOWABLE SFLOWABLE ;; services|SERVICES) ## 12、启动SERVICE SSERVICE ;; equipment|EQUIPMENT) ## 13、启动EQUIPMENT SEQUIPMENT ;; safe|SAFE) ## 14、启动SAFE SSAFE ;; envpro|ENVPRO) ## 15、启动ENVPRO SENVPRO ;; education|EDUCATION) ## 16、启动EDUCATION SEDUCATION ;; quartz|QUARTZ) ## 17、启动QUARTZ SQUARTZ ;; report|REPORT) ## 18、启动REPORT SREPORT ;; all|ALL) ## 1、启动BUS SBUS ## 2、启动organization SORGANIZATION ## 3、启动AUTHORIZATION SAUTHORIZATION ## 4、启动AUTHENTICATION SAUTHENTICATION ## 5、启动GATEWAYADMIN SGATEWAYADMIN ## 6、启动GATEWAY SGATEWAY ## 7、启动LOG SLOG ## 8、启动XFILE SXFILE ## 9、启动MONITOR SMONITOR ## 10、启动SOCKETIO SSOCKETIO ## 11、启动FLOWABLE SFLOWABLE ## 12、启动SERVICE SSERVICE ## 13、启动EQUIPMENT SEQUIPMENT ## 14、启动SAFE SSAFE ## 15、启动ENVPRO SENVPRO ## 16、启动EDUCATION SEDUCATION ## 17、启动QUARTZ SQUARTZ ## 18、启动REPORT SREPORT echo "===startAll success===" ;; esac ;; stop) case "$2" in bus|BUS) ## 1、停止BUS EBUS ;; organization|ORGANIZATION) ## 2、停止organization EORGANIZATION ;; authorization|AUTHORIZATION) ## 3、停止AUTHORIZATION EAUTHORIZATION ;; authentication|AUTHENTICATION) ## 4、停止AUTHENTICATION EAUTHENTICATION ;; gatewayadmin|GATEWAYADMIN) ## 5、停止GATEWAYADMIN EGATEWAYADMIN ;; gateway|GATEWAY) ## 6、停止GATEWAY EGATEWAY ;; log|LOG) ## 7、停止LOG ELOG ;; xfile|XFILE) ## 8、停止XFILE EXFILE ;; monitor|MONITOR) ## 9、停止MONITOR EMONITOR ;; socketio|SOCKETIO) ## 10、停止SOCKETIO ESOCKETIO ;; flowable|FLOWABLE) ## 11、停止FLOWABLE EFLOWABLE ;; services|SERVICES) ## 12、停止SERVICE ESERVICE ;; equipment|EQUIPMENT) ## 13、停止EQUIPMENT EEQUIPMENT ;; safe|SAFE) ## 14、停止SAFE ESAFE ;; envpro|ENVPRO) ## 15、停止ENVPRO EENVPRO ;; education|EDUCATION) ## 16、停止EDUCATION EEDUCATION ;; quartz|QUARTZ) ## 17、停止QUARTZ EQUARTZ ;; report|REPORT) ## 18、停止REPORT EREPORT ;; all|ALL) ## 1、停止BUS EBUS ## 2、停止ORGANIZATION EORGANIZATION ## 3、停止AUTHORIZATION EAUTHORIZATION ## 4、停止AUTHENTICATION EAUTHENTICATION ## 5、停止GATEWAYADMIN EGATEWAYADMIN ## 6、停止GATEWAY EGATEWAY ## 7、停止LOG ELOG ## 8、停止XFILE EXFILE ## 9、停止MONITOR EMONITOR ## 10、停止SOCKETIO ESOCKETIO ## 11、停止FLOWABLE EFLOWABLE ## 12、停止SERVICE ESERVICE ## 13、停止EQUIPMENT EEQUIPMENT ## 14、停止SAFE ESAFE ## 15、停止ENVPRO EENVPRO ## 16、停止EDUCATION EEDUCATION ## 17、停止QUARTZ EQUARTZ ## 18、停止REPORT EREPORT echo "===stopAll success===" ;; esac ;; restart)case "$2" in bus|BUS) ## 1、重启BUS sh $0 stop bus sleep 2 sh $0 start bus ;; organization|ORGANIZATION) ## 2、重启organization sh $0 stop organization sleep 2 sh $0 start organization ;; authorization|AUTHORIZATION) ## 3、重启AUTHORIZATION sh $0 stop authorization sleep 2 sh $0 start authorization ;; authentication|AUTHENTICATION) ## 4、重启AUTHENTICATION sh $0 stop authentication sleep 2 sh $0 start authentication ;; gatewayadmin|GATEWAYADMIN) ## 5、重启GATEWAYADMIN sh $0 stop gatewayadmin sleep 2 sh $0 start gatewayadmin ;; gateway|GATEWAY) ## 6、重启GATEWAY sh $0 stop gateway sleep 2 sh $0 start gateway ;; log|LOG) ## 7、重启LOG sh $0 stop log sleep 2 sh $0 start log ;; xfile|XFILE) ## 8、重启XFILE sh $0 stop xfile sleep 2 sh $0 start xfile ;; monitor|MONITOR) ## 9、重启MONITOR sh $0 stop monitor sleep 2 sh $0 start monitor ;; socketio|SOCKETIO) ## 10、重启SOCKETIO sh $0 stop socketio sleep 2 sh $0 start socketio ;; flowable|FLOWABLE) ## 11、重启FLOWABLE sh $0 stop flowable sleep 2 sh $0 start flowable ;; services|SERVICES) ## 12、重启SERVICE sh $0 stop services sleep 2 sh $0 start services ;; equipment|EQUIPMENT) ## 13、重启EQUIPMENT sh $0 stop equipment sleep 2 sh $0 start equipment ;; safe|SAFE) ## 14、重启SAFE sh $0 stop safe sleep 2 sh $0 start safe ;; envpro|ENVPRO) ## 15、重启ENVPRO sh $0 stop envpro sleep 2 sh $0 start envpro ;; education|EDUCATION) ## 16、重启EDUCATION sh $0 stop education sleep 2 sh $0 start education ;; quartz|QUARTZ) ## 17、重启QUARTZ sh $0 stop quartz sleep 2 sh $0 start quartz ;; report|REPORT) ## 18、重启REPORT sh $0 stop report sleep 2 sh $0 start report ;; all|ALL) sh $0 stop all sleep 10 sh $0 start all echo "===restartAll success===" ;; esac ;; esac exit 0
转载地址:http://ugtxz.baihongyu.com/