docker 优化

pull/588/head
Mr Chen 11 months ago
parent f1f0a0f1a5
commit efc4fb9cb2
  1. 13
      class/core/mw.py
  2. 19
      plugins/mysql/index.py

@ -199,6 +199,7 @@ def getFileSuffix(file):
return ext return ext
def isAppleSystem(): def isAppleSystem():
if getOs() == 'darwin': if getOs() == 'darwin':
return True return True
@ -208,6 +209,18 @@ def isDocker():
return os.path.exists('/.dockerenv') return os.path.exists('/.dockerenv')
def isSupportSystemctl():
if isAppleSystem():
return False
if isDocker():
return False
current_os = getOs()
if current_os.startswith("freebsd"):
return False
return True
def isDebugMode(): def isDebugMode():
if isAppleSystem(): if isAppleSystem():
return True return True

@ -589,23 +589,22 @@ def myOp(version, method):
isInited = initMysqlData() isInited = initMysqlData()
if not isInited: if not isInited:
if current_os.startswith("freebsd"): if not mw.isSupportSystemctl():
mw.execShell('service ' + getPluginName() + ' start') mw.execShell('service ' + getPluginName() + ' start')
else: else:
mw.execShell('systemctl start mysql') mw.execShell('systemctl start mysql')
initMysqlPwd() initMysqlPwd()
if current_os.startswith("freebsd"): if not mw.isSupportSystemctl():
mw.execShell('service ' + getPluginName() + ' stop') mw.execShell('service ' + getPluginName() + ' stop')
else: else:
mw.execShell('systemctl stop mysql') mw.execShell('systemctl stop mysql')
if current_os.startswith("freebsd"): if not mw.isSupportSystemctl():
data = mw.execShell('service ' + getPluginName() + ' ' + method) mw.execShell('service ' + getPluginName() + ' ' + method)
return 'ok' else:
mw.execShell('systemctl ' + method + ' mysql')
mw.execShell('systemctl ' + method + ' mysql')
return 'ok' return 'ok'
except Exception as e: except Exception as e:
return str(e) return str(e)
@ -627,7 +626,7 @@ def my8cmd(version, method):
if not isInited: if not isInited:
if mw.isAppleSystem(): if not mw.isSupportSystemctl():
cmd_init_start = init_file + ' start' cmd_init_start = init_file + ' start'
subprocess.Popen(cmd_init_start, stdout=subprocess.PIPE, shell=True, subprocess.Popen(cmd_init_start, stdout=subprocess.PIPE, shell=True,
bufsize=4096, stderr=subprocess.PIPE) bufsize=4096, stderr=subprocess.PIPE)
@ -643,7 +642,7 @@ def my8cmd(version, method):
break break
time.sleep(1) time.sleep(1)
if mw.isAppleSystem(): if not mw.isSupportSystemctl():
cmd_init_stop = init_file + ' stop' cmd_init_stop = init_file + ' stop'
subprocess.Popen(cmd_init_stop, stdout=subprocess.PIPE, shell=True, subprocess.Popen(cmd_init_stop, stdout=subprocess.PIPE, shell=True,
bufsize=4096, stderr=subprocess.PIPE) bufsize=4096, stderr=subprocess.PIPE)
@ -651,7 +650,7 @@ def my8cmd(version, method):
else: else:
mw.execShell('systemctl stop mysql') mw.execShell('systemctl stop mysql')
if mw.isAppleSystem(): if not mw.isSupportSystemctl():
sub = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, sub = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True,
bufsize=4096, stderr=subprocess.PIPE) bufsize=4096, stderr=subprocess.PIPE)
sub.wait(5) sub.wait(5)

Loading…
Cancel
Save