From f6090022de18746098f104418e99d156af7ff5a5 Mon Sep 17 00:00:00 2001 From: chenxudong Date: Thu, 12 Jun 2025 17:41:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + src/ComacDBInstall.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index d98c921..b0ecaf5 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ build/ ComacDBInstall.spec src/__pycache__/Test.cpython-311.pyc dist/ComacDBInstall.exe +src/Test.py diff --git a/src/ComacDBInstall.py b/src/ComacDBInstall.py index 999b800..196038d 100644 --- a/src/ComacDBInstall.py +++ b/src/ComacDBInstall.py @@ -186,7 +186,7 @@ class InstallComacDb: self.jar_path = get_resource_path(os.path.join("datas", "electromagnetic.jar")) self.new_java_path = 'D:/database/jdk/bin/java.exe' self.url = f'http://127.0.0.1:{self.comac_db_running_port}/index' - self.service_name = "comacDatabase" + self.service_name = "ComacDatabase" self.service_description = "数据库组件服务" # 路径配置 self.datas_dir = get_resource_path(os.path.join('datas')) @@ -200,11 +200,7 @@ class InstallComacDb: def start_comac_db(self): self.__delete_old_files(self.app_log_dir) - existStatus = check_service_exist(self.service_name) - if existStatus: - start_service_if_not_running(self.service_name) - return - + self.__remove_pre_service() self.__register_and_start_service() pass @@ -274,6 +270,13 @@ class InstallComacDb: subprocess.run(rf"net start {self.service_name}") time.sleep(10) + def __remove_pre_service(self): + stop_command = ["sc", "stop", self.service_name] + delete_command = ["sc", "delete", self.service_name] + subprocess.run(stop_command, capture_output=True, text=True) + subprocess.run(delete_command, capture_output=True, text=True) + pass + if __name__ == '__main__': InstallMariaDb().start_install_mariadb()