Skip to content

Commit 0da77d8

Browse files
committed
feat: 재시도 로직 작성
1 parent b2d75bf commit 0da77d8

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

scripts/start-loadtest.ps1

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,21 @@ docker-compose -p projectvg-loadtest --env-file env.loadtest -f docker-compose.l
3535

3636
# Wait for services to start
3737
Write-Host "Waiting for services to start..." -ForegroundColor Yellow
38-
Start-Sleep -Seconds 3
3938

40-
# Check service status
41-
Write-Host "Checking service status..." -ForegroundColor Yellow
39+
function Wait-ForUrl {
40+
param([string]$url, [int]$timeoutSec=120)
41+
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
42+
while ($stopwatch.Elapsed.TotalSeconds -lt $timeoutSec) {
43+
try {
44+
$resp = Invoke-WebRequest -Uri $url -TimeoutSec 3 -UseBasicParsing
45+
if ($resp.StatusCode -eq 200) { return $true }
46+
} catch { Start-Sleep -Milliseconds 500 }
47+
}
48+
return $false
49+
}
50+
51+
# Check service status with retry
52+
Write-Host "Checking service status with retry..." -ForegroundColor Yellow
4253

4354
$services = @(
4455
@{Name="LLM Server"; Url="http://localhost:7808/health"},
@@ -49,16 +60,13 @@ $services = @(
4960

5061
$allHealthy = $true
5162
foreach ($service in $services) {
52-
try {
53-
$response = Invoke-RestMethod -Uri $service.Url -TimeoutSec 3
54-
if ($response.status -eq "ok" -or $response.Status -eq "Healthy") {
55-
Write-Host "$($service.Name): OK" -ForegroundColor Green
56-
} else {
57-
Write-Host "$($service.Name): FAILED" -ForegroundColor Red
58-
$allHealthy = $false
59-
}
60-
} catch {
61-
Write-Host "$($service.Name): CONNECTION FAILED" -ForegroundColor Red
63+
Write-Host "Waiting for $($service.Name)..." -ForegroundColor Cyan
64+
$isHealthy = Wait-ForUrl -url $service.Url -timeoutSec 120
65+
66+
if ($isHealthy) {
67+
Write-Host "$($service.Name): OK" -ForegroundColor Green
68+
} else {
69+
Write-Host "$($service.Name): TIMEOUT (120s)" -ForegroundColor Red
6270
$allHealthy = $false
6371
}
6472
}

0 commit comments

Comments
 (0)