From c0eb2f2670799ae9966b74ae1eb8e255502ba527 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Wed, 12 Dec 2018 18:45:33 +0800 Subject: [PATCH] update --- .gitignore | 1 + class/core/config.py | 2 ++ scripts/init.d/mw.tpl | 22 +++++++++++++++++++++- setting.py | 14 ++++++++------ 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index d06ac5370..705c9dbd3 100644 --- a/.gitignore +++ b/.gitignore @@ -113,3 +113,4 @@ data/json/index.json data/*.db data/control.conf scripts/init.d/mw +logs/* diff --git a/class/core/config.py b/class/core/config.py index 84923cb3b..0e0c9aa64 100644 --- a/class/core/config.py +++ b/class/core/config.py @@ -51,6 +51,8 @@ class config: def initInitD(self): script = public.getRunDir() + '/scripts/init.d/mw.tpl' script_bin = public.getRunDir() + '/scripts/init.d/mw' + if os.path.exists(script_bin): + return content = public.readFile(script) content = content.replace("{$SERVER_PATH}", public.getRunDir()) diff --git a/scripts/init.d/mw.tpl b/scripts/init.d/mw.tpl index c2a53a0ba..b7a3a915e 100755 --- a/scripts/init.d/mw.tpl +++ b/scripts/init.d/mw.tpl @@ -14,7 +14,7 @@ mw_start(){ if [ "$isStart" == '' ];then echo -e "\033[31mfailed\033[0m" echo '------------------------------------------------------' - tail -n 20 $panel_path/logs/error.log + tail -n 20 $mw_path/logs/error.log echo '------------------------------------------------------' echo -e "\033[31mError: mw service startup failed.\033[0m" return; @@ -23,6 +23,26 @@ mw_start(){ else echo "Starting mw... mw(pid $(echo $isStart)) already running" fi + + + 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 } diff --git a/setting.py b/setting.py index 1df2fc07b..b87a46340 100755 --- a/setting.py +++ b/setting.py @@ -4,6 +4,8 @@ import sys sys.path.append(os.getcwd() + '/class/core') import public +if not os.path.exists(os.getcwd() + '/logs'): + os.mkdir(os.getcwd() + '/logs') bt_port = public.readFile('data/port.pl') bind = ['0.0.0.0:%s' % bt_port] @@ -16,12 +18,12 @@ timeout = 7200 keepalive = 1 # worker_class = 'geventwebsocket.gunicorn.workers.GeventWebSocketWorker' chdir = os.getcwd() -# capture_output = True -# access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"' -# loglevel = 'info' -# errorlog = chdir + '/logs/error.log' -# accesslog = chdir + '/logs/access.log' -# pidfile = chdir + '/logs/panel.pid' +capture_output = True +access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"' +loglevel = 'info' +errorlog = os.getcwd() + '/logs/error.log' +accesslog = os.getcwd() + '/logs/access.log' +pidfile = os.getcwd() + '/logs/mw.pid' # if os.path.exists(chdir + '/data/ssl.pl'): # certfile = 'ssl/certificate.pem' # keyfile = 'ssl/privateKey.pem'