/app/all_start_script/wwyt/此目录服务如下:apigateway.sh auth.sh config.sh register.sh zipkin.sh
/app/all_start_script/other/此目录服务如下:
tomcat.sh wwyt_base.sh wwyt_cache.sh wwyt_flow.sh wwyt_risk_login.sh wwyt_rule.sh
/app/all_start_script/startall//此目录服务如下:base_start_all.sh fk_all_start.sh
/app/all_start_script/stopall/此目录服务如下:fk_all_stop.sh
脚本版本一如下:
#!/bin/bash
dirsh="/app/all_start_script/wwyt/"
service="/app/all_start_script/fksh"
script="/app/all_start_script/fkscript"
base="/app/all_start_script/other/"
fkall="/app/all_start_script/startall/"
stopscript="/app/all_start_script/stopall/"
javajar="java -jar"
tomcat="tomcat"
baseall=0
basetotal=0
wwyttotal=0
fktotal=0
stopall=0
trap "rm -f $script $service;exit" INT
execscript(){while read seqfilenum seqname doif [ "$2" -eq "$seqfilenum" ];then$3$seqnamerm -rf $4 $1fidone<$1}
existdir(){if [ -d $1 ];thencd $1ls>>$2ls |wc -lelseecho -e "\n \e[1;31m $1目录不存在 \e[0m"fi
}
stopservice(){while read filenum seqname doecho $1 $4if [ "$1" -ne "$4" ];thenif [ "$1" -eq "$filenum" ];thenrm -rf $2 $3 kill -9 $(ps -ef | grep ${seqname%.sh}| awk '{print $2}') &> /dev/null fielserm -rf $2 $3kill -9 $(ps -ef | grep "${javajar}\|$tomcat"| awk '{print $2}') &> /dev/nullfidone<$2
}
fileexist(){if [ -d `dirname $1` ];thenif [ -e $1 ];thenrm -rf $1fielseecho -e "\n \e[1;31m $(dirname $1)目录不存在 \e[0m"exitfi
}
fileexist $script
fileexist $service
basetotal=`existdir $base $service`
wwyttotal=`existdir $dirsh $service`
case ""$1 instart)fktotal=`existdir $fkall $service`total=$((wwyttotal+basetotal+fktotal));;stop)stoptotal=`existdir $stopscript $service`total=$((wwyttotal+basetotal+stoptotal));;check)ps -ef | grep "$javajar\|$tomcat"fileexist $serviceexit;;log)echo $1;;*)echo -e "\e[1;32m\n启动服务输入参数start\n停止服务输入参数stop\n检查服务输入参数check\n\e[0m"fileexist $serviceexitesac
singletotal=$((wwyttotal+basetotal))
cd `dirname $service`
echo -e "\e[1;32m----五位一体风控服务列表----\e[0m"cat -n $service|tee -a $script
echo -e "\e[1;32m----------------------------\e[0m"read -n 2 -p "请选择要启动的服务(输入数字序号):" num
echo -e "\n"if [[ ! $num =~ ^[0-9]+$ ]];thenecho -e "\n \e[1;31m 请输入数字 \e[0m"rm -rf $service $scriptexit 1fi case "$1" instart)if [ "$num" -gt 0 -a "$num" -le "$total" ];thenif [ "$num" -le "$basetotal" ];thenexecscript $script $num $base $serviceelif [ "$num" -gt "$basetotal" -a "$num" -le "$singletotal" ];thenexecscript $script $num $dirsh $serviceelseexecscript $script $num $fkall $servicefirm -rf $service $scriptelseecho -e "\n \033[31m 请输入大于0小于等于${total}的数字 \033[0m"rm -rf $service $scriptfi ;;stop)stopservice $num $script $service $total ;;log) ;;*) ;;
esac
基础服务启动脚本:
#!/bin/bash
dirsh="/app/all_start_script/other"
cd $dirsh
./register.sh
register=0
config=0
api=0
zipkin=0
echo "register 启动中。。"
while (($register <3))
do
register=`netstat -tnulp|grep 1900[123]|wc -l`
done
echo "register 启动成功。。" ./config.sh
echo "config 启动中。。。"
while (($config< 3))
do
config=`netstat -tnulp|grep 999[678]|wc -l`
done
echo "config 启动成功。。。"./apigateway.sh
echo "api 启动成中。。。"
while (($api==1))
do
api=`netstat -tnulp | grep 18001|wc -l`
done
echo "api 启动成功。。。"./zipkin.sh
echo "zipkin 启动成中。。。"
while (($zipkin==1))
do
zipkin=`ps -ef |grep -v grep| grep zipkin|wc -l`
done
echo "zipkin启动成功。。。"
系统服务启动脚本:
#!/bin/bash
dirsh="/app/all_start_script/wwyt/"
service="/app/all_start_script/fkallfilesh"
cd $dirsh
ls -l | grep -v "总用量"|awk -F ' ' '{print $9}'>$service
while read line
do
echo $line"启动中。。"$dirsh$line
done<$service
rm -rf $service
register脚本内容:
#!/bin/bash
#kill -9 `ps -ef | grep register| awk '{print $2}'` &> /dev/null &
cd /app/eureka-server
i=1
while [ $i -le 1 ] ;do let i++
nohup java -jar uap-register-server-1.0.jar --spring.profiles.active=register01 &> /app/log/eureka-register01.log &
nohup java -jar uap-register-server-1.0.jar --spring.profiles.active=register02 &> /app/log/eureka-register02.log &
nohup java -jar uap-register-server-1.0.jar --spring.profiles.active=register03 &> /app/log/eureka-register03.log &
done
config脚本内容
#!/bin/bash
#kill -9 `ps -ef | grep config| awk '{print $2}'` &> /dev/null
cd /app/config-server
i=1
while [ $i -le 1 ];
do
let i++
nohup java -jar uap-config-server-1.0.jar --spring.config.location=application-config01.properties,bootstrap.properties &> /app/log/config01.log &
nohup java -jar uap-config-server-1.0.jar --spring.config.location=application-config02.properties,bootstrap.properties &> /app/log/config02.log &
nohup java -jar uap-config-server-1.0.jar --spring.config.location=application-config03.properties,bootstrap.properties &> /app/log/config03.log &
done
zipkin脚本内容
#!/bin/bash
#kill -9 `ps -ef | grep zipkin| awk '{print $2}'` &> /dev/null
cd /app/zipkin
nohup java -jar uap-tracemonitor-server-1.0.jar --STORAGE_TYPE=mysql --MYSQL_DB=zipkin --MYSQL_USER=dbscale --MYSQL_PASS=dbscale --MYSQL_HOST=192.168.66.105 --MYSQL_TCP_PORT=13007 --spring.config.location=application.properties &> /app/log/zipkin.log &