Skip to content

Commit

Permalink
Merge pull request #588 from midoks/dev
Browse files Browse the repository at this point in the history
docker相关功能优化
  • Loading branch information
midoks authored Jun 7, 2024
2 parents 7f69686 + efc4fb9 commit 64f15e7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
16 changes: 16 additions & 0 deletions class/core/mw.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,27 @@ def getFileSuffix(file):
return ext



def isAppleSystem():
if getOs() == 'darwin':
return True
return False

def isDocker():
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():
if isAppleSystem():
Expand Down
19 changes: 9 additions & 10 deletions plugins/mysql/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,23 +589,22 @@ def myOp(version, method):
isInited = initMysqlData()
if not isInited:

if current_os.startswith("freebsd"):
if not mw.isSupportSystemctl():
mw.execShell('service ' + getPluginName() + ' start')
else:
mw.execShell('systemctl start mysql')

initMysqlPwd()

if current_os.startswith("freebsd"):
if not mw.isSupportSystemctl():
mw.execShell('service ' + getPluginName() + ' stop')
else:
mw.execShell('systemctl stop mysql')

if current_os.startswith("freebsd"):
data = mw.execShell('service ' + getPluginName() + ' ' + method)
return 'ok'

mw.execShell('systemctl ' + method + ' mysql')
if not mw.isSupportSystemctl():
mw.execShell('service ' + getPluginName() + ' ' + method)
else:
mw.execShell('systemctl ' + method + ' mysql')
return 'ok'
except Exception as e:
return str(e)
Expand All @@ -627,7 +626,7 @@ def my8cmd(version, method):

if not isInited:

if mw.isAppleSystem():
if not mw.isSupportSystemctl():
cmd_init_start = init_file + ' start'
subprocess.Popen(cmd_init_start, stdout=subprocess.PIPE, shell=True,
bufsize=4096, stderr=subprocess.PIPE)
Expand All @@ -643,15 +642,15 @@ def my8cmd(version, method):
break
time.sleep(1)

if mw.isAppleSystem():
if not mw.isSupportSystemctl():
cmd_init_stop = init_file + ' stop'
subprocess.Popen(cmd_init_stop, stdout=subprocess.PIPE, shell=True,
bufsize=4096, stderr=subprocess.PIPE)
time.sleep(3)
else:
mw.execShell('systemctl stop mysql')

if mw.isAppleSystem():
if not mw.isSupportSystemctl():
sub = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True,
bufsize=4096, stderr=subprocess.PIPE)
sub.wait(5)
Expand Down

0 comments on commit 64f15e7

Please sign in to comment.