refactor: Improve PostgreSQL connection readiness check #1300

Replace wait-for-it with pg_isready for PostgreSQL readiness check.
This commit is contained in:
xuwei-fit2cloud
2026-09-21 10:52:30 +08:00
committed by GitHub
parent f48d7828c9
commit 311e01ce35
+12 -2
View File
@@ -2,8 +2,18 @@ SSR_PATH=/opt/sqlbot/g2-ssr
APP_PATH=/opt/sqlbot/app
/usr/local/bin/docker-entrypoint.sh postgres &
sleep 5
wait-for-it 127.0.0.1:5432 --timeout=120 --strict -- echo -e "\033[1;32mPostgreSQL started.\033[0m"
MAX_WAIT=120
WAIT_COUNT=0
echo "Waiting for PostgreSQL to complete crash recovery and accept connections (max ${MAX_WAIT}s)..."
until pg_isready -h 127.0.0.1 -p 5432 -U postgres -q; do
if [ $WAIT_COUNT -ge $MAX_WAIT ]; then
echo -e "\033[1;31mError: PostgreSQL failed to become ready within ${MAX_WAIT} seconds. Exiting to avoid hanging.\033[0m"
exit 1
fi
sleep 2
WAIT_COUNT=$((WAIT_COUNT + 2))
done
echo -e "\033[1;32mPostgreSQL is fully ready and accepting connections (took ${WAIT_COUNT}s).\033[0m"
nohup /usr/bin/supervisord -c /etc/supervisor/supervisord.conf &