mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
refactor: Improve PostgreSQL connection readiness check #1300
Replace wait-for-it with pg_isready for PostgreSQL readiness check.
This commit is contained in:
@@ -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 &
|
||||
|
||||
|
||||
Reference in New Issue
Block a user