Skip to content

Commit

Permalink
Added waiting instead of sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
MarhiievHE committed Jan 26, 2024
1 parent c20ba52 commit f9336ae
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,22 @@ jobs:
echo "port = 5432" >> "$PGDATA/postgresql.conf"
$PG_BIN = "C:\Program Files\PostgreSQL\14\bin"
$env:PATH = "$PG_BIN;$env:PATH"
Write-Host "PATH=$env:PATH"
# Write-Host "PATH=$env:PATH"
# start and wait
pg_ctl start
Start-Sleep -Seconds 15
$timeout = 120
$elapsedTime = 0
Write-Host "Waiting for PostgreSQL to start"
while ($elapsedTime -lt $timeout) {
$pgIsReadyResult = & $PG_BIN\pg_isready.exe -h localhost -p 5432 -t 1
if ($pgIsReadyResult -eq "localhost:5432 - accepting connections") {
Write-Host "PostgreSQL is ready"
break
}
Start-Sleep -Seconds 5
$elapsedTime += 5
}
# setup db
cd database
Expand All @@ -72,6 +83,26 @@ jobs:
sc.exe create Redis binpath=C:\redis\RedisService.exe start= auto
net start Redis
# wait for redis
Write-Host "Waiting for Redis to start"
while ($elapsedTime -lt $timeout) {
$redisPingResult = & C:\redis\redis-cli.exe ping
echo $redisPingResult
if ($redisPingResult -eq "PONG") {
Write-Host "Redis is ready"
break
}
Start-Sleep -Seconds 5
$elapsedTime += 5
}
if ($elapsedTime -ge $timeout) {
Write-Host "Timeout waiting for services to start."
exit 1
}
Write-Host "Services are ready"
- name: Setup (on Linux)
if: runner.os == 'Linux'
run: |
Expand Down

0 comments on commit f9336ae

Please sign in to comment.