diff --git a/class/plugin/orm.py b/class/plugin/orm.py index 562d16906..aac2b9e36 100755 --- a/class/plugin/orm.py +++ b/class/plugin/orm.py @@ -24,13 +24,26 @@ class ORM: '''连接数据库''' try: - try: - self.__DB_CONN = pymysql.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=1, unix_socket=self.__DB_SOCKET, cursorclass=pymysql.cursors.DictCursor) - except Exception as e: - self.__DB_HOST = '127.0.0.1' - self.__DB_CONN = pymysql.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=1, unix_socket=self.__DB_SOCKET, cursorclass=pymysql.cursors.DictCursor) + if os.path.exists(self.__DB_SOCKET): + try: + self.__DB_CONN = pymysql.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=1, + unix_socket=self.__DB_SOCKET, cursorclass=pymysql.cursors.DictCursor) + except Exception as e: + self.__DB_HOST = '127.0.0.1' + self.__DB_CONN = pymysql.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=1, + unix_socket=self.__DB_SOCKET, cursorclass=pymysql.cursors.DictCursor) + else: + try: + self.__DB_CONN = pymysql.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=1, + cursorclass=pymysql.cursors.DictCursor) + except Exception as e: + self.__DB_HOST = '127.0.0.1' + self.__DB_CONN = pymysql.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=1, + cursorclass=pymysql.cursors.DictCursor) self.__DB_CUR = self.__DB_CONN.cursor() return True diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 117483239..de76df55e 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -1656,10 +1656,6 @@ def addMasterRepSlaveUser(version=''): def getMasterRepSlaveUserCmd(version): - version_pl = getServerDir() + "/version.pl" - if os.path.exists(version_pl): - version = mw.readFile(version_pl).strip() - args = getArgs() data = checkArgs(args, ['username', 'db']) if not data[0]: @@ -1681,8 +1677,8 @@ def getMasterRepSlaveUserCmd(version): ip = mw.getLocalIp() port = getMyPort() - db = pMysqlDb() + mstatus = db.query('show master status') if len(mstatus) == 0: return mw.returnJson(False, '未开启!') @@ -1915,14 +1911,17 @@ def initSlaveStatus(version=''): def setSlaveStatus(version=''): + db = pMysqlDb() dlist = db.query('show slave status') if len(dlist) == 0: - return mw.returnJson(False, '需要手动添加主服务同步命令或者执行[初始化]!') + return mw.returnJson(False, '需要手动添加主服务命令或者执行[初始化]!') if len(dlist) > 0 and (dlist[0]["Slave_IO_Running"] == 'Yes' or dlist[0]["Slave_SQL_Running"] == 'Yes'): db.query('stop slave') else: + + print(dlist[0]) db.query('start slave') return mw.returnJson(True, '设置成功!') @@ -1959,17 +1958,6 @@ def dumpMysqlData(version): return 'fail' -from threading import Thread -from time import sleep - - -def mw_async(f): - def wrapper(*args, **kwargs): - thr = Thread(target=f, args=args, kwargs=kwargs) - thr.start() - return wrapper - - ############### --- 重要 同步---- ########### def writeDbSyncStatus(data): @@ -2147,8 +2135,9 @@ if __name__ == "__main__": func = sys.argv[1] version = "5.6" - if (len(sys.argv) > 2): - version = sys.argv[2] + version_pl = getServerDir() + "/version.pl" + if os.path.exists(version_pl): + version = mw.readFile(version_pl).strip() if func == 'status': print(status(version)) diff --git a/plugins/mysql/js/mysql.js b/plugins/mysql/js/mysql.js index 50ac5ee1d..1f5e903c3 100755 --- a/plugins/mysql/js/mysql.js +++ b/plugins/mysql/js/mysql.js @@ -1034,9 +1034,9 @@ function myLogs(){ var line_status = "" if (rdata.status){ line_status = '\ - ' + '; } else { - line_status = '' + line_status = ''; } var limitCon = '
\ @@ -1044,7 +1044,7 @@ function myLogs(){ '+line_status+'\
错误日志
\ \ - ' + '; $(".soft-man-con").html(limitCon); //设置二进制日志