From 39646f0b0189464d1f158cf977e64240ccab3836 Mon Sep 17 00:00:00 2001 From: None Date: Tue, 10 Feb 2026 23:00:35 -0600 Subject: [PATCH] Fix modular mode PostgreSQL/Redis connection checks Replace raw Python AF_INET socket checks with pg_isready (PostgreSQL) and socket.create_connection (Redis) in modular deployment mode The raw socket check may fail in some Docker environments depending on networking and DNS configurations, causing indefinite hangs. Replaced database check with native pg_isready and memstore checck with AF_UNSPEC in the case IPv6 is enabled. Fixes #952 --- docker/entrypoint.sh | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 8ea47318..b79af952 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -163,20 +163,9 @@ if [[ "$DISPATCHARR_ENV" != "modular" ]]; then pids+=("$postgres_pid") else echo "🔗 Modular mode: Using external PostgreSQL at ${POSTGRES_HOST}:${POSTGRES_PORT}" - # Wait for external PostgreSQL to be ready using Python (no pg_isready needed) + # Wait for external PostgreSQL to be ready using pg_isready (checks actual protocol readiness) echo_with_timestamp "Waiting for external PostgreSQL to be ready..." - until python3 -c " -import socket -import sys -try: - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.settimeout(2) - s.connect(('${POSTGRES_HOST}', ${POSTGRES_PORT})) - s.close() - sys.exit(0) -except Exception: - sys.exit(1) -" 2>/dev/null; do + until $PG_BINDIR/pg_isready -h "${POSTGRES_HOST}" -p "${POSTGRES_PORT}" -q >/dev/null 2>&1; do echo_with_timestamp "Waiting for PostgreSQL at ${POSTGRES_HOST}:${POSTGRES_PORT}..." sleep 1 done @@ -191,12 +180,9 @@ if [[ "$DISPATCHARR_ENV" == "modular" ]]; then echo "🔗 Modular mode: Using external Redis at ${REDIS_HOST}:${REDIS_PORT}" echo_with_timestamp "Waiting for external Redis to be ready..." until python3 -c " -import socket -import sys +import socket, sys try: - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.settimeout(2) - s.connect(('${REDIS_HOST}', ${REDIS_PORT})) + s = socket.create_connection(('${REDIS_HOST}', ${REDIS_PORT}), timeout=2) s.close() sys.exit(0) except Exception: