From 2663fd7a991351a08034a64eb4ebf961f1b30216 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 3 Jul 2022 11:18:55 +0800 Subject: [PATCH] =?UTF-8?q?php502=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- task.py | 60 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/task.py b/task.py index 67f486cd6..01d6745ff 100755 --- a/task.py +++ b/task.py @@ -432,34 +432,40 @@ def startPHPVersion(version): def checkPHPVersion(version): try: url = 'http://127.0.0.1/phpfpm_status_' + version - result = mw.httpGet(url) - # print(version,result) - # 检查openresty - if result.find('Bad Gateway') != -1: - return False - if result.find('HTTP Error 404: Not Found') != -1: - return False - - # 检查Web服务是否启动 - if result.find('Connection refused') != -1: - global isTask - if os.path.exists(isTask): - isStatus = mw.readFile(isTask) - if isStatus == 'True': - return True - - # systemd - systemd = '/lib/systemd/system/openresty.service' - if os.path.exists(systemd): - execShell('systemctl reload openresty') + result = mw.httpGet(url, 1) + if result.find('timed out'): + raise + except Exception as e: + url = 'http://' + mw.getLocalIp() + '/phpfpm_status_' + version + result = mw.httpGet(url, 1) + else: + result = 'Bad Gateway' + + # print(version,result) + # 检查openresty + if result.find('Bad Gateway') != -1: + return False + if result.find('HTTP Error 404: Not Found') != -1: + return False + + # 检查Web服务是否启动 + if result.find('Connection refused') != -1: + global isTask + if os.path.exists(isTask): + isStatus = mw.readFile(isTask) + if isStatus == 'True': return True - # initd - initd = '/etc/init.d/openresty' - if os.path.exists(initd): - os.system(initd + ' reload') - return True - except: - return True + + # systemd + systemd = '/lib/systemd/system/openresty.service' + if os.path.exists(systemd): + execShell('systemctl reload openresty') + return True + # initd + initd = '/etc/init.d/openresty' + if os.path.exists(initd): + os.system(initd + ' reload') + return True # --------------------------------------PHP监控 end--------------------------------------------- #