This commit is contained in:
parent
33e7efa440
commit
b0a6181dca
|
|
@ -412,8 +412,7 @@ class config_api:
|
|||
choose_file = self.__file['ssl']
|
||||
mw.writeFile(choose_file, 'local')
|
||||
|
||||
import system_api
|
||||
system_api.system_api().restartMw()
|
||||
mw.restartMw()
|
||||
return mw.returnJson(True, '设置成功')
|
||||
|
||||
# 关闭SSL
|
||||
|
|
@ -430,12 +429,13 @@ class config_api:
|
|||
if os.path.exists(nginx_ssl):
|
||||
mw.execShell('rm -rf '+ nginx_ssl)
|
||||
|
||||
import system_api
|
||||
system_api.system_api().restartMw()
|
||||
mw.restartMw()
|
||||
return mw.returnJson(True, '关闭SSL成功')
|
||||
|
||||
# 保存面板证书
|
||||
def savePanelSslApi(self):
|
||||
|
||||
|
||||
keyPath = 'ssl/private.pem'
|
||||
certPath = 'ssl/cert.pem'
|
||||
checkCert = '/tmp/cert.pl'
|
||||
|
|
@ -455,7 +455,6 @@ class config_api:
|
|||
mw.writeFile(certPath, certPem)
|
||||
if not mw.checkCert(checkCert):
|
||||
return mw.returnJson(False, '证书错误,请检查!')
|
||||
mw.writeFile('ssl/input.pl', 'True')
|
||||
return mw.returnJson(True, '证书已保存!')
|
||||
|
||||
# 设置面板SSL证书设置
|
||||
|
|
@ -502,7 +501,7 @@ class config_api:
|
|||
conf = re.sub(rep, '', conf)
|
||||
mw.writeFile(panel_ssl, conf)
|
||||
|
||||
mw.restartWeb()
|
||||
mw.restartNginx()
|
||||
|
||||
action = '开启'
|
||||
if is_https == 'true':
|
||||
|
|
@ -530,10 +529,10 @@ class config_api:
|
|||
mw.execShell('rm -rf ' + dst_csrpath)
|
||||
if os.path.exists(dst_keypath):
|
||||
mw.execShell('rm -rf ' + dst_keypath)
|
||||
# mw.restartWeb()
|
||||
mw.restartNginx()
|
||||
return mw.returnJson(True, '已经删除SSL!')
|
||||
|
||||
# mw.restartWeb()
|
||||
mw.restartNginx()
|
||||
return mw.returnJson(False, '已经不存在SSL!')
|
||||
|
||||
# 申请面板let证书
|
||||
|
|
@ -564,7 +563,7 @@ class config_api:
|
|||
content = content.replace("{$LOGPATH}", mw.getRunDir() + '/logs')
|
||||
content = content.replace("{$PANAL_ADDR}", mw.getRunDir())
|
||||
mw.writeFile(dst_panel_path, content)
|
||||
mw.restartWeb()
|
||||
mw.restartNginx()
|
||||
|
||||
siteName = mw.readFile(bind_domain).strip()
|
||||
auth_to = mw.getRunDir() + "/tmp"
|
||||
|
|
|
|||
|
|
@ -347,6 +347,9 @@ def restartMw():
|
|||
import system_api
|
||||
system_api.system_api().restartMw()
|
||||
|
||||
def restartNginx(self):
|
||||
writeFile('data/restart_nginx.pl', 'True')
|
||||
return True
|
||||
|
||||
def checkWebConfig():
|
||||
op_dir = getServerDir() + '/openresty/nginx'
|
||||
|
|
|
|||
50
task.py
50
task.py
|
|
@ -64,6 +64,29 @@ def service_cmd(method):
|
|||
return
|
||||
|
||||
|
||||
def openresty_cmd(method = 'reload'):
|
||||
# 检查是否安装
|
||||
odir = mw.getServerDir() + '/openresty'
|
||||
if not os.path.exists(odir):
|
||||
return False
|
||||
|
||||
# systemd
|
||||
systemd = mw.systemdCfgDir()+'/openresty.service'
|
||||
if os.path.exists(systemd):
|
||||
execShell('systemctl ' + method + ' openresty')
|
||||
return True
|
||||
|
||||
sys_initd = '/etc/init.d/openresty'
|
||||
if os.path.exists(install_initd):
|
||||
os.system(sys_initd + ' ' + method)
|
||||
return True
|
||||
|
||||
install_initd = mw.getServerDir()+'/openresty/init.d/openresty'
|
||||
if os.path.exists(install_initd):
|
||||
os.system(install_initd + ' ' + method)
|
||||
return True
|
||||
return False
|
||||
|
||||
def mw_async(f):
|
||||
def wrapper(*args, **kwargs):
|
||||
thr = threading.Thread(target=f, args=args, kwargs=kwargs)
|
||||
|
|
@ -539,13 +562,7 @@ def openrestyAutoRestart():
|
|||
time.sleep(86400)
|
||||
continue
|
||||
|
||||
# systemd
|
||||
systemd = mw.systemdCfgDir()+'/openresty.service'
|
||||
initd = '/etc/init.d/openresty'
|
||||
if os.path.exists(systemd):
|
||||
execShell('systemctl reload openresty')
|
||||
elif os.path.exists(initd):
|
||||
os.system(initd + ' reload')
|
||||
openresty_cmd('reload')
|
||||
time.sleep(86400)
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
|
@ -553,6 +570,18 @@ def openrestyAutoRestart():
|
|||
|
||||
# --------------------------------------OpenResty Auto Restart End --------------------------------------------- #
|
||||
|
||||
# ------------------------------------ OpenResty Restart At Once Start ------------------------------------------ #
|
||||
|
||||
|
||||
def openrestyRestartAtOnce():
|
||||
restart_nginx_tip = 'data/restart_nginx.pl'
|
||||
while True:
|
||||
if os.path.exists(restartTip):
|
||||
os.remove(restartTip)
|
||||
openresty_cmd('reload')
|
||||
time.sleep(1)
|
||||
# ----------------------------------- OpenResty Restart At Once End ------------------------------------------ #
|
||||
|
||||
|
||||
# --------------------------------------Panel Restart Start --------------------------------------------- #
|
||||
def restartPanelService():
|
||||
|
|
@ -584,11 +613,18 @@ if __name__ == "__main__":
|
|||
php502 = setDaemon(php502)
|
||||
php502.start()
|
||||
|
||||
# OpenResty Restart At Once Start
|
||||
oraos = threading.Thread(target=openrestyRestartAtOnce)
|
||||
oraos = setDaemon(oraos)
|
||||
oraos.start()
|
||||
|
||||
|
||||
# OpenResty Auto Restart Start
|
||||
oar = threading.Thread(target=openrestyAutoRestart)
|
||||
oar = setDaemon(oar)
|
||||
oar.start()
|
||||
|
||||
|
||||
# Panel Restart Start
|
||||
rps = threading.Thread(target=restartPanelService)
|
||||
rps = setDaemon(rps)
|
||||
|
|
|
|||
Loading…
Reference in New Issue