File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,11 +43,22 @@ jobs:
4343 echo "port = 5432" >> "$PGDATA/postgresql.conf"
4444 $PG_BIN = "C:\Program Files\PostgreSQL\14\bin"
4545 $env:PATH = "$PG_BIN;$env:PATH"
46- Write-Host "PATH=$env:PATH"
46+ # Write-Host "PATH=$env:PATH"
4747
4848 # start and wait
4949 pg_ctl start
50- Start-Sleep -Seconds 15
50+ $timeout = 120
51+ $elapsedTime = 0
52+ Write-Host "Waiting for PostgreSQL to start"
53+ while ($elapsedTime -lt $timeout) {
54+ $pgIsReadyResult = & $PG_BIN\pg_isready.exe -h localhost -p 5432 -t 1
55+ if ($pgIsReadyResult -eq "localhost:5432 - accepting connections") {
56+ Write-Host "PostgreSQL is ready"
57+ break
58+ }
59+ Start-Sleep -Seconds 5
60+ $elapsedTime += 5
61+ }
5162
5263 # setup db
5364 cd database
7283 sc.exe create Redis binpath=C:\redis\RedisService.exe start= auto
7384 net start Redis
7485
86+ # wait for redis
87+ Write-Host "Waiting for Redis to start"
88+ while ($elapsedTime -lt $timeout) {
89+ $redisPingResult = & C:\redis\redis-cli.exe ping
90+ echo $redisPingResult
91+ if ($redisPingResult -eq "PONG") {
92+ Write-Host "Redis is ready"
93+ break
94+ }
95+ Start-Sleep -Seconds 5
96+ $elapsedTime += 5
97+ }
98+
99+ if ($elapsedTime -ge $timeout) {
100+ Write-Host "Timeout waiting for services to start."
101+ exit 1
102+ }
103+
104+ Write-Host "Services are ready"
105+
75106 - name : Setup (on Linux)
76107 if : runner.os == 'Linux'
77108 run : |
You can’t perform that action at this time.
0 commit comments