Skip to content

Commit 03c9431

Browse files
committed
Update cli.sh
1 parent 43e3ea7 commit 03c9431

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

cli.sh

+25-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,33 @@ fi
1111

1212
# export LC_ALL="en_US.UTF-8"
1313

14+
15+
mw_start_task()
16+
{
17+
isStart=$(ps aux |grep 'task.py'|grep -v grep|awk '{print $2}')
18+
if [ "$isStart" == '' ];then
19+
echo -e "Starting mw-tasks... \c"
20+
cd $DIR && python3 task.py >> ${DIR}/logs/task.log 2>&1 &
21+
sleep 0.3
22+
isStart=$(ps aux |grep 'task.py'|grep -v grep|awk '{print $2}')
23+
if [ "$isStart" == '' ];then
24+
echo -e "\033[31mfailed\033[0m"
25+
echo '------------------------------------------------------'
26+
tail -n 20 $DIR/logs/task.log
27+
echo '------------------------------------------------------'
28+
echo -e "\033[31mError: mw-tasks service startup failed.\033[0m"
29+
return;
30+
fi
31+
echo -e "\033[32mdone\033[0m"
32+
else
33+
echo "Starting mw-tasks... mw-tasks (pid $(echo $isStart)) already running"
34+
fi
35+
}
36+
1437
mw_start(){
1538
gunicorn -c setting.py app:app
16-
python3 task.py >> $DIR/logs/task.log 2>&1 &
39+
#安全启动
40+
mw_start_task
1741
}
1842

1943

0 commit comments

Comments
 (0)