Simple Linux Panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mdserver-web/scripts/init.d/mw.tpl

55 lines
1.9 KiB

7 years ago
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
mw_path={$SERVER_PATH}
mw_start(){
isStart=`ps -ef|grep 'gunicorn -c setting.py app:app' |grep -v grep|awk '{print $2}'`
if [ "$isStart" == '' ];then
echo -e "Starting mw... \c"
cd $mw_path && gunicorn -c setting.py app:app &
sleep 0.1
port=$(cat ${mw_path}/data/port.pl)
isStart=$(lsof -i :$port|grep LISTEN)
if [ "$isStart" == '' ];then
echo -e "\033[31mfailed\033[0m"
echo '------------------------------------------------------'
7 years ago
tail -n 20 $mw_path/logs/error.log
7 years ago
echo '------------------------------------------------------'
echo -e "\033[31mError: mw service startup failed.\033[0m"
return;
fi
echo -e "\033[32mdone\033[0m"
else
echo "Starting mw... mw(pid $(echo $isStart)) already running"
fi
7 years ago
isStart=$(ps aux |grep 'task.py'|grep -v grep|awk '{print $2}')
if [ "$isStart" == '' ];then
echo -e "Starting mw-tasks... \c"
nohup python task.py >> $mw_path/logs/task.log 2>&1 &
sleep 0.2
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 $mw_path/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... Bt-Tasks (pid $isStart) already running"
fi
7 years ago
}
case "$1" in
'start')
mw_start
;;
esac