From 3b7e56b4cf0e2dc2ff9e43f149ae5d49c4d4a80a Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Fri, 28 Dec 2018 17:02:38 +0800 Subject: [PATCH] update --- class/core/system_api.py | 23 ++++++++++++++++++++--- scripts/init.d/mw.tpl | 2 +- setting.py | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/class/core/system_api.py b/class/core/system_api.py index be0ce2cfc..550126fc2 100755 --- a/class/core/system_api.py +++ b/class/core/system_api.py @@ -15,6 +15,17 @@ import public import config +from threading import Thread +from time import sleep + + +def async(f): + def wrapper(*args, **kwargs): + thr = Thread(target=f, args=args, kwargs=kwargs) + thr.start() + return wrapper + + class system_api: setupPath = None pids = None @@ -72,12 +83,18 @@ class system_api: # 重启面板 def restartApi(self): - cmd = public.getRunDir() + '/scripts/init.d/mw start' - public.execShell(cmd) + self.restartMw() return public.returnJson(True, '面板已重启!') ##### ----- end ----- ### - # 名取PID + @async + def restartMw(self): + sleep(1) + print '123123' + cmd = public.getRunDir() + '/scripts/init.d/mw reload' + print public.execShell(cmd) + + # 名取PID def getPid(self, pname): try: if not self.pids: diff --git a/scripts/init.d/mw.tpl b/scripts/init.d/mw.tpl index 8c594a9a6..d7de0ace0 100755 --- a/scripts/init.d/mw.tpl +++ b/scripts/init.d/mw.tpl @@ -8,7 +8,7 @@ mw_start(){ if [ "$isStart" == '' ];then echo -e "Starting mw... \c" cd $mw_path && gunicorn -c setting.py app:app - sleep 0.6 + sleep 0.2 port=$(cat ${mw_path}/data/port.pl) isStart=$(lsof -i :$port|grep LISTEN) if [ "$isStart" == '' ];then diff --git a/setting.py b/setting.py index 835f4acbe..e63fdd39f 100755 --- a/setting.py +++ b/setting.py @@ -18,7 +18,7 @@ bind = ['0.0.0.0:%s' % bt_port] workers = cpu_info[1] + 1 threads = 1 backlog = 512 -reload = False +reload = True daemon = True timeout = 7200 keepalive = 1