yum安裝
yum install cronolog
項(xiàng)目啟動(dòng)Shell腳本
JARARRAY=(auth.jar oss-server.jar admin-server.jar gateway.jar monitor.jar device-manage-server.jar)
PORTARRAY=(8081 8083 8082 8080 8100 8087)
NACOS_NAMESPACE="5d304c31-67d5-412321321321321321321"
case "$1" in
start)
echo "--------------- start --------------------"
# for CURRJAR in ${JARARRAY[*]}
for((i=0;i<${#JARARRAY[*]};i++))
do
#CURR_PID = `lsof -i:$CENTER_port|grep "LISTEN"|awk '{print $2}'`
nohup java -jar ${JARARRAY[$i]} -Xms32m -Xmx64m --nacos-namespace=${NACOS_NAMESPACE} 2>&1 | cronolog logs/${JARARRAY[$i]}/log.%Y-%m-%d.out >> /dev/null &
echo "===================start ${JARARRAY[$i]} ================================"
CURR_PID=`lsof -i:${PORTARRAY[$i]}|grep 'LISTEN'|awk '{print $2}'`
until [ $CURR_PID ]
do
CURR_PID=`lsof -i:${PORTARRAY[$i]}|grep 'LISTEN'|awk '{print $2 }'`
done
echo "--------------- ${JARARRAY[$i]} start finish -----------------"
done
echo "--------------- start finish --------------------"
;;
stop)
echo "--------------- stop --------------------"
for CURRJAR in ${JARARRAY[*]}
do
CURR_PID=`ps -ef | grep -w $CURRJAR | grep -v "grep" | awk '{print $2}'`
if [ "$CURR_PID" == "" ]; then
echo "=== process not exists or stop success"
else
kill -9 $CURR_PID
echo "------------ $CURRJAR stop success --------------- "
fi
done
echo "--------------- stop finish --------------------"
;;
restart)
$0 stop
sleep 2
$0 start
echo "------------- restart finish-------------------"
;;
esac
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者