Skip to content
Snippets Groups Projects
Verified Commit 2e5d89b0 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

[Docker] Use `SELECT 1` to wait for database

This removes the need to have host and port as environment
variables (we might get it in a YAML file from a K8s ConfigMap, or
some such). Also, it ensures that the system answering is a database
rather than an IoT Waffeleisen with a bad taste in port selection.
parent 885cd0c1
No related branches found
No related tags found
1 merge request!535[Docker] Use `SELECT 1` to wait for database
Pipeline #6445 passed
......@@ -2,9 +2,6 @@
HTTP_PORT=${HTTP_PORT:8000}
export ALEKSIS_database__host=${ALEKSIS_database__host:-127.0.0.1}
export ALEKSIS_database__port=${ALEKSIS_database__port:-5432}
if [[ -z $ALEKSIS_secret_key ]]; then
if [[ ! -e /var/lib/aleksis/secret_key ]]; then
touch /var/lib/aleksis/secret_key; chmod 600 /var/lib/aleksis/secret_key
......@@ -13,9 +10,12 @@ if [[ -z $ALEKSIS_secret_key ]]; then
ALEKSIS_secret_key=$(</var/lib/aleksis/secret_key)
fi
while ! nc -z $ALEKSIS_database__host $ALEKSIS_database__port; do
sleep 0.1
echo -n "Waiting for database."
while ! aleksis-admin dbshell -- -c "SELECT 1" >/dev/null 2>&1; do
sleep 0.5
echo -n .
done
echo
aleksis-admin migrate
aleksis-admin createinitialrevisions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment