优化重启和任务功能

pull/109/head
Mr Chen 6 years ago
parent e5143e3125
commit 02e0bc71d9
  1. 3
      class/core/system_api.py
  2. 20
      task.py

@ -103,7 +103,8 @@ class system_api:
@async @async
def restartMw(self): def restartMw(self):
sleep(1) sleep(1)
cmd = public.getRunDir() + '/scripts/init.d/mw reload' cmd = public.getRunDir() + '/scripts/init.d/mw restart'
#print cmd
public.execShell(cmd) public.execShell(cmd)
@async @async

@ -7,6 +7,7 @@ import sys
import os import os
import json import json
import time import time
import threading
# print sys.path # print sys.path
sys.path.append("/usr/local/lib/python2.7/site-packages") sys.path.append("/usr/local/lib/python2.7/site-packages")
@ -38,6 +39,19 @@ if not os.path.exists(isTask):
os.system("touch " + 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(): class MyBad():
_msg = None _msg = None
@ -326,9 +340,7 @@ def systemTask():
reloadNum += 1 reloadNum += 1
if reloadNum > 1440: if reloadNum > 1440:
reloadNum = 0 reloadNum = 0
# if os.path.exists('data/ssl.pl'): restartMw()
cmd = public.getRunDir() + '/scripts/init.d/mw restart > /dev/null 2>&1'
os.system(cmd)
except Exception, ex: except Exception, ex:
print str(ex) print str(ex)
@ -428,7 +440,7 @@ def checkPHPVersion(version):
if __name__ == "__main__": if __name__ == "__main__":
import threading
t = threading.Thread(target=systemTask) t = threading.Thread(target=systemTask)
t.setDaemon(True) t.setDaemon(True)
t.start() t.start()

Loading…
Cancel
Save