diff --git a/cli.sh b/cli.sh index f38e77abb..2ca2de7d8 100755 --- a/cli.sh +++ b/cli.sh @@ -11,9 +11,33 @@ fi # export LC_ALL="en_US.UTF-8" + +mw_start_task() +{ + isStart=$(ps aux |grep 'task.py'|grep -v grep|awk '{print $2}') + if [ "$isStart" == '' ];then + echo -e "Starting mw-tasks... \c" + cd $DIR && python3 task.py >> ${DIR}/logs/task.log 2>&1 & + sleep 0.3 + isStart=$(ps aux |grep 'task.py'|grep -v grep|awk '{print $2}') + if [ "$isStart" == '' ];then + echo -e "\033[31mfailed\033[0m" + echo '------------------------------------------------------' + tail -n 20 $DIR/logs/task.log + echo '------------------------------------------------------' + echo -e "\033[31mError: mw-tasks service startup failed.\033[0m" + return; + fi + echo -e "\033[32mdone\033[0m" + else + echo "Starting mw-tasks... mw-tasks (pid $(echo $isStart)) already running" + fi +} + mw_start(){ gunicorn -c setting.py app:app - python3 task.py >> $DIR/logs/task.log 2>&1 & + #安全启动 + mw_start_task }