From f22e10a496624cc2aba4b88aed13e1ccb3f00566 Mon Sep 17 00:00:00 2001 From: JiRan <54714341+h88782481@users.noreply.github.com> Date: Sun, 11 Sep 2022 18:40:41 +0800 Subject: [PATCH 1/2] Update mw.py --- class/core/mw.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From fd35db3dd8f15270fe1a4535d0c0e5aacd9ecc7b Mon Sep 17 00:00:00 2001 From: JiRan <54714341+h88782481@users.noreply.github.com> Date: Sun, 11 Sep 2022 18:45:44 +0800 Subject: [PATCH 2/2] Update index.py --- plugins/openresty/index.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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():