优化日志输出。
This commit is contained in:
parent
f439ca8167
commit
459b5cc92a
|
|
@ -32,7 +32,12 @@ class InstallMariaDb:
|
|||
args1 = 'net'
|
||||
args2 = 'start'
|
||||
res = subprocess.run([args1, args2, self.service_name], text=True, capture_output=True)
|
||||
if res.returncode != 0:
|
||||
logger.info(res.stdout)
|
||||
logger.info("服务启动失败")
|
||||
logger.error(res.stderr)
|
||||
else:
|
||||
logger.info("服务启动成功")
|
||||
|
||||
def __register_service(self):
|
||||
args1 = self.root_path + '/mariadb/bin/mysql_install_db.exe'
|
||||
|
|
@ -41,8 +46,12 @@ class InstallMariaDb:
|
|||
args4 = '--password=' + self.passowrd
|
||||
args5 = '--port=' + str(self.mariadb_port)
|
||||
res = subprocess.run([args1, args2, args3, args4, args5], text=True, capture_output=True)
|
||||
if res.returncode != 0:
|
||||
logger.info(res.stdout)
|
||||
return res
|
||||
logger.info("服务注册失败")
|
||||
logger.error(res.stderr)
|
||||
else:
|
||||
logger.info("服务注册成功")
|
||||
|
||||
def __init_db_user(self):
|
||||
command1 = fr'{self.root_path}\mariadb\bin\mysql.exe -u root -p{self.passowrd} -P {self.mariadb_port} -e "create database if not exists {self.init_schema}; use {self.init_schema};"'
|
||||
|
|
@ -56,6 +65,7 @@ class InstallMariaDb:
|
|||
if not os.path.exists(schema_dir):
|
||||
logger.error("数据库初始化失败")
|
||||
raise MyCustomError("数据库安装失败")
|
||||
logger.info("数据库初始化成功")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
Loading…
Reference in New Issue