Commit c6ccdcfe authored by Stefan Bienert's avatar Stefan Bienert
Browse files

Added function to test database connections for Django container

parent 1e6842a4
......@@ -27,6 +27,25 @@ sys.exit(0)
END
}
function postgres_ready(){
python3 << END
import sys
import cathapi.wsgi
from django.db import connections
from django.db.utils import OperationalError
db_conn = connections['default']
try:
db_conn.cursor()
except OperationalError:
sys.stderr.write("Database not yet available.\n")
sys.exit(1)
except:
raise
sys.exit(2)
sys.exit(0)
END
}
# exit immediately on commands with a non-zero exit status.
set -e
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment