|
|
@ -392,7 +392,7 @@ def startPHPVersion(version): |
|
|
|
try: |
|
|
|
try: |
|
|
|
|
|
|
|
|
|
|
|
# system |
|
|
|
# system |
|
|
|
phpService = '/lib/systemd/system/php' + version + '.service' |
|
|
|
phpService = mw.systemdCfgDir() + '/php' + version + '.service' |
|
|
|
if os.path.exists(phpService): |
|
|
|
if os.path.exists(phpService): |
|
|
|
mw.execShell("systemctl restart php" + version) |
|
|
|
mw.execShell("systemctl restart php" + version) |
|
|
|
if checkPHPVersion(version): |
|
|
|
if checkPHPVersion(version): |
|
|
@ -439,17 +439,42 @@ def startPHPVersion(version): |
|
|
|
return True |
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getFpmConfFile(version): |
|
|
|
|
|
|
|
return mw.getServerDir() + '/php/' + version + '/etc/php-fpm.d/www.conf' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getFpmAddress(version): |
|
|
|
|
|
|
|
fpm_address = '/tmp/php-cgi-{}.sock'.format(version) |
|
|
|
|
|
|
|
php_fpm_file = getFpmConfFile(version) |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
content = readFile(php_fpm_file) |
|
|
|
|
|
|
|
tmp = re.findall(r"listen\s*=\s*(.+)", content) |
|
|
|
|
|
|
|
if not tmp: |
|
|
|
|
|
|
|
return fpm_address |
|
|
|
|
|
|
|
if tmp[0].find('sock') != -1: |
|
|
|
|
|
|
|
return fpm_address |
|
|
|
|
|
|
|
if tmp[0].find(':') != -1: |
|
|
|
|
|
|
|
listen_tmp = tmp[0].split(':') |
|
|
|
|
|
|
|
if bind: |
|
|
|
|
|
|
|
fpm_address = (listen_tmp[0], int(listen_tmp[1])) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
fpm_address = ('127.0.0.1', int(listen_tmp[1])) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
fpm_address = ('127.0.0.1', int(tmp[0])) |
|
|
|
|
|
|
|
return fpm_address |
|
|
|
|
|
|
|
except: |
|
|
|
|
|
|
|
return fpm_address |
|
|
|
|
|
|
|
|
|
|
|
# 检查指定PHP版本 |
|
|
|
# 检查指定PHP版本 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def checkPHPVersion(version): |
|
|
|
def checkPHPVersion(version): |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
url = 'http://127.0.0.1/phpfpm_status_' + version |
|
|
|
sock = getFpmAddress(version) |
|
|
|
result = mw.httpGet(url, 1) |
|
|
|
data = mw.requestFcgiPHP(sock, '/phpfpm_status_' + version + '?json') |
|
|
|
if result.find('timed out'): |
|
|
|
result = str(data, encoding='utf-8') |
|
|
|
raise |
|
|
|
|
|
|
|
except Exception as e: |
|
|
|
except Exception as e: |
|
|
|
url = 'http://' + mw.getLocalIp() + '/phpfpm_status_' + version |
|
|
|
|
|
|
|
result = mw.httpGet(url, 1) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
result = 'Bad Gateway' |
|
|
|
result = 'Bad Gateway' |
|
|
|
|
|
|
|
|
|
|
|
# print(version,result) |
|
|
|
# print(version,result) |
|
|
@ -468,7 +493,7 @@ def checkPHPVersion(version): |
|
|
|
return True |
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
# systemd |
|
|
|
# systemd |
|
|
|
systemd = '/lib/systemd/system/openresty.service' |
|
|
|
systemd = mw.systemdCfgDir() + '/openresty.service' |
|
|
|
if os.path.exists(systemd): |
|
|
|
if os.path.exists(systemd): |
|
|
|
execShell('systemctl reload openresty') |
|
|
|
execShell('systemctl reload openresty') |
|
|
|
return True |
|
|
|
return True |
|
|
|