From dd630f3eede85ce60efc8865bac8ce07a6e6985b Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 26 Jun 2022 20:15:14 +0800 Subject: [PATCH] for mac debug --- plugins/mysql/index.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index bebe16c66..d13d6e5db 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -406,6 +406,7 @@ def myOp(version, method): def my8cmd(version, method): # mysql 8.0 and 5.7 init_file = initDreplace(version) + cmd = init_file + ' ' + method try: if version == '5.7': isInited = initMysql57Data() @@ -413,11 +414,32 @@ def my8cmd(version, method): isInited = initMysql8Data() if not isInited: - mw.execShell('systemctl start mysql') + + if mw.isAppleSystem(): + cmd_init_start = init_file + ' start' + subprocess.Popen(cmd_init_start, stdout=subprocess.PIPE, shell=True, + bufsize=4096, stderr=subprocess.PIPE) + + time.sleep(6) + else: + mw.execShell('systemctl start mysql') + initMysql8Pwd() - mw.execShell('systemctl stop mysql') - mw.execShell('systemctl ' + method + ' mysql') + if mw.isAppleSystem(): + 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(): + sub = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, + bufsize=4096, stderr=subprocess.PIPE) + sub.wait(5) + else: + mw.execShell('systemctl ' + method + ' mysql') return 'ok' except Exception as e: return str(e)