#!/bin/bash
function run_and_sleep () {
script_path=$1
echo $script_path
sleep_time=$2
eval "$script_path"
`sleep ${sleep_time}`
}
#run_and_sleep "~/my/test.sh" "10s"
function stop_or_restart_maz_process() {
pName=$1
pSleepTime=$2
str=$(ps -ef | grep "${pName}".jar)
arr=()
while read -r line; do
arr+=("$line")
done <<< "$str"
myLength="${#arr[@]}"
O_IFS=$IFS
if [ $myLength -eq 2 ];then
for val in "${arr[@]}"
do
IFS=' '
read -a arr_item <<< "$val"
pidItem="${arr_item[1]}"
jarNameItem="${arr_item[9]}"
if [[ -n $jarNameItem ]];then
`kill -9 $pidItem`
run_and_sleep "~/sunagy/${pName}/start.sh" $pSleepTime
fi
done
else
run_and_sleep "~/sunagy/${pName}/start.sh" $pSleepTime
fi
IFS=$O_IFS
}
rm -rf ~/sunagy/maz-admin/maz-admin.log ~/sunagy/maz-auth/maz-auth.log ~/sunagy/maz-dict/maz-dict.log ~/sunagy/maz-platform-teabug/maz-platform-teabug.log ~/sunagy/maz-gate/maz-gate.log ~/sunagy/maz-qrcode/maz-qrcode.log ~/sunagy/maz-center/maz-center.log
stop_or_restart_maz_process "maz-center" "10s"
stop_or_restart_maz_process "maz-auth" "20s"
stop_or_restart_maz_process "maz-gate" "18s"
stop_or_restart_maz_process "maz-dict" "18s"
stop_or_restart_maz_process "maz-admin" "5m"
stop_or_restart_maz_process "maz-qrcode" "18s"
stop_or_restart_maz_process "maz-platform-teabug" "10s"