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()