Skip to content

Commit 664365d

Browse files
steventuxCopilot
andcommitted
Check that service is Running when starting
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent b86ac82 commit 664365d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

scripts/powershell/maintenance.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,14 @@ function Start-AllServices {
7171
if ($status -and $status.Status -eq 'Running') { break }
7272
Start-Sleep -Milliseconds 500
7373
}
74+
$stopwatch.Stop()
7475

75-
Write-Log "$($svc.Name) started." "SUCCESS"
76-
}
76+
$finalStatus = Get-Service -Name $svc.Name -ErrorAction SilentlyContinue
77+
if (-not $finalStatus -or $finalStatus.Status -ne 'Running') {
78+
throw "Service $($svc.Name) did not start within ${TimeoutSeconds}s (state: $($finalStatus.Status))."
79+
}
80+
81+
Write-Log "$($svc.Name) started in $([math]::Round($stopwatch.Elapsed.TotalSeconds, 1))s." "SUCCESS"
7782
}
7883

7984
# -- Database backup ----------------------------------------------------------

0 commit comments

Comments
 (0)