From 02e0bc71d9ab7254beacfa5ae9b43649d5bbf09a Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Fri, 19 Apr 2019 10:37:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=87=8D=E5=90=AF=E5=92=8C?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/system_api.py | 3 ++- task.py | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/class/core/system_api.py b/class/core/system_api.py index 2de1259f7..a54533e1e 100755 --- a/class/core/system_api.py +++ b/class/core/system_api.py @@ -103,7 +103,8 @@ class system_api: @async def restartMw(self): sleep(1) - cmd = public.getRunDir() + '/scripts/init.d/mw reload' + cmd = public.getRunDir() + '/scripts/init.d/mw restart' + #print cmd public.execShell(cmd) @async diff --git a/task.py b/task.py index 8edaf1cbb..af180cfef 100755 --- a/task.py +++ b/task.py @@ -7,6 +7,7 @@ import sys import os import json import time +import threading # print sys.path sys.path.append("/usr/local/lib/python2.7/site-packages") @@ -38,6 +39,19 @@ if not os.path.exists(isTask): os.system("touch " + isTask) +def async(f): + def wrapper(*args, **kwargs): + thr = threading.Thread(target=f, args=args, kwargs=kwargs) + thr.start() + return wrapper + +@async +def restartMw(): + sleep(1) + cmd = public.getRunDir() + '/scripts/init.d/mw restart' + public.execShell(cmd) + + class MyBad(): _msg = None @@ -326,9 +340,7 @@ def systemTask(): reloadNum += 1 if reloadNum > 1440: reloadNum = 0 - # if os.path.exists('data/ssl.pl'): - cmd = public.getRunDir() + '/scripts/init.d/mw restart > /dev/null 2>&1' - os.system(cmd) + restartMw() except Exception, ex: print str(ex) @@ -428,7 +440,7 @@ def checkPHPVersion(version): if __name__ == "__main__": - import threading + t = threading.Thread(target=systemTask) t.setDaemon(True) t.start()