Skip to content
Snippets Groups Projects
Commit 3d67716d authored by HeJ's avatar HeJ
Browse files

docker: make check_psql more resilient

parent 0603c1a9
Branches
Tags
No related merge requests found
......@@ -13,10 +13,10 @@ if [[ "$1" != "build" ]]; then
RETRIES=10
until postgres_healthcheck; do
if [[ ${RETRIES} -eq 0 ]]; then
echo "Failed to connect to database"
echo "\nFailed to connect to database."
exit 1
fi
echo "Waiting for database readiness ..."
echo -en "\nWaiting for database readiness ... "
sleep 1
RETRIES=$((RETRIES-1))
done
......
#!/usr/local/bin/python
#!/usr/bin/env python3
import os
import sys
try:
import psycopg
except ImportError:
import psycopg2 as psycopg
url = os.getenv("DATABASE_URL")
if url is None or url == '':
print('No DATABASE_URL specified!', file=sys.stderr)
sys.exit(2)
try:
psycopg.connect(os.getenv("DATABASE_URL"))
except Exception:
if url.startswith('postgis://'):
url = 'postgresql://' + url[len('postgis://'):]
psycopg.connect(url)
except Exception as err:
print('ERROR', file=sys.stderr)
print(' ', err, sep='', file=sys.stderr)
exit(1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment