diff --git a/class/core/mw.py b/class/core/mw.py index b2a5bad74..c4cb1d603 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -167,13 +167,13 @@ def restartWeb(): # systemd systemd = '/lib/systemd/system/openresty.service' if os.path.exists(systemd): - execShell('systemctl restart openresty') + execShell('systemctl reload openresty') return True # initd initd = getServerDir() + '/openresty/init.d/openresty' if os.path.exists(initd): - execShell(initd + ' ' + 'restart') + execShell(initd + ' ' + 'reload') return True return False diff --git a/plugins/openresty/index.py b/plugins/openresty/index.py index 489a2571c..2efc7c70c 100755 --- a/plugins/openresty/index.py +++ b/plugins/openresty/index.py @@ -215,6 +215,29 @@ def restyOp(method): return 'ok' return data[1] +def submit_restart1(): + mw.execShell('systemctl restart openresty') + +def submit_restart2(file): + mw.execShell(file + ' restart') + +def restyOp_restart(): + file = initDreplace() + + # 启动时,先检查一下配置文件 + check = getServerDir() + "/bin/openresty -t" + check_data = mw.execShell(check) + if not check_data[1].find('test is successful') > -1: + return check_data[1] + + if not mw.isAppleSystem(): + threading.Timer(5,submit_restart1,args=()).start() + #submit_restart1() + return 'ok' + + threading.Timer(5,submit_restart2,args=(file)).start() + #submit_restart2(file) + return 'ok' def start(): return restyOp('start') @@ -225,13 +248,14 @@ def stop(): def restart(): - return restyOp('restart') + return restyOp_restart() def reload(): return restyOp('reload') + def initdStatus(): if mw.isAppleSystem():