Skip to content

Commit 6eea5bd

Browse files
committed
more trying to fix unix socket specs
1 parent a3012a5 commit 6eea5bd

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

spec/postgres.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,18 @@ function start {
5757

5858
echo "$(tput setaf 4)Waiting for server to be ready$(tput sgr0)"
5959
if [ "$1" = "unix" ]; then
60-
# For unix socket mode, actually try to connect via the socket from the host
61-
until (PGHOST="$socket_dir" PGUSER=postgres PGPASSWORD=pgmoon psql -c 'SELECT 1' 2> /dev/null); do
62-
sleep 0.1
60+
# For unix socket mode, we need to wait past the init restart cycle.
61+
# During init, postgres listens on unix socket with listen_addresses='',
62+
# then shuts down and restarts in production mode.
63+
# Require 3 successful connections with delays to ensure we're past init.
64+
success_count=0
65+
while [ $success_count -lt 3 ]; do
66+
if PGHOST="$socket_dir" PGUSER=postgres PGPASSWORD=pgmoon psql -c 'SELECT 1' > /dev/null 2>&1; then
67+
success_count=$((success_count + 1))
68+
else
69+
success_count=0
70+
fi
71+
sleep 0.3
6372
done
6473
else
6574
until (PGHOST=127.0.0.1 PGPORT=$port PGUSER=postgres PGPASSWORD=pgmoon psql -c 'SELECT pg_reload_conf()' 2> /dev/null); do :; done

0 commit comments

Comments
 (0)