优化重启和任务功能
This commit is contained in:
parent
e5143e3125
commit
02e0bc71d9
|
|
@ -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
|
||||
|
|
|
|||
20
task.py
20
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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue