diff --git a/scripts/init.d/mw.tpl b/scripts/init.d/mw.tpl index 10b5923f3..d2620f4c7 100755 --- a/scripts/init.d/mw.tpl +++ b/scripts/init.d/mw.tpl @@ -8,9 +8,18 @@ mw_start(){ if [ "$isStart" == '' ];then echo -e "Starting mw... \c" cd $mw_path && gunicorn -c setting.py app:app - sleep 0.2 port=$(cat ${mw_path}/data/port.pl) - isStart=$(lsof -i :$port|grep LISTEN) + isStart="" + while [[ "$isStart" == "" ]]; + do + echo -e ".\c" + sleep 0.5 + isStart=$(lsof -n -P -i:$port|grep LISTEN|grep -v grep|awk '{print $2}'|xargs) + let n+=1 + if [ $n -gt 8 ];then + break; + fi + done if [ "$isStart" == '' ];then echo -e "\033[31mfailed\033[0m" echo '------------------------------------------------------'