fix: installer tolerates localized 'service exists' (1073) and restarts the service if an upgrade step fails; 1.1.7

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
gti
2026-09-24 11:13:19 -03:00
co-authored by Claude Sonnet 5
parent 55e858e261
commit f5f05d87e6
21 changed files with 68 additions and 29 deletions
+2 -1
View File
@@ -201,7 +201,8 @@ def install_service(install_dir_path: Path) -> None:
exe = Path(install_dir_path) / "GTIFiscalAgentService" / "GTIFiscalAgentService.exe"
bin_path = f"\"{exe}\""
result = _sc(["create", SERVICE_NAME, "binPath=", bin_path, "start=", "auto", "DisplayName=", SERVICE_DISPLAY])
if result.returncode != 0 and "already exists" not in (result.stdout + result.stderr):
# 1073 = ERROR_SERVICE_EXISTS. Match the code, never the message: the text is localized (pt-BR: "já existe").
if result.returncode not in (0, 1073) and "already exists" not in (result.stdout + result.stderr):
raise RuntimeError(f"sc create failed: {result.stdout} {result.stderr}".strip())
_sc(["config", SERVICE_NAME, "start=", "delayed-auto"])
_sc(["config", SERVICE_NAME, "obj=", "LocalSystem"])