From a234fb04862229756bb71cd36c72fc8fa6e1d66b Mon Sep 17 00:00:00 2001 From: Oliver Keeble <oliver.keeble@cern.ch> Date: Mon, 7 Jun 2021 14:15:33 +0200 Subject: [PATCH] Add a pause/retry to init to wait for db to come up, needed for local postgres container --- .../docker/ctafrontend/cc7/opt/run/bin/init.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init.sh b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init.sh index 33a6719f96..2c697ad77a 100755 --- a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init.sh +++ b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init.sh @@ -73,7 +73,13 @@ echo ${DATABASEURL} >/etc/cta/cta-catalogue.conf if [ "$KEEP_DATABASE" == "0" ]; then echo "Wiping database" if [ "$DATABASETYPE" != "sqlite" ]; then - echo yes | cta-catalogue-schema-drop /etc/cta/cta-catalogue.conf || die "ERROR: Could not wipe database. cta-catalogue-schema-drop /etc/cta/cta-catalogue.conf FAILED" + if ! (echo yes | cta-catalogue-schema-drop /etc/cta/cta-catalogue.conf); then + # pause to let db come up + echo "Database connection failed, pausing before a retry" + sleep 5 + echo yes | cta-catalogue-schema-drop /etc/cta/cta-catalogue.conf || die "ERROR: Could not wipe database. cta-catalogue-schema-drop /etc/cta/cta-catalogue.conf FAILED" + echo "Database wiped" + fi else rm -fr $(dirname $(echo ${DATABASEURL} | cut -d: -f2)) fi -- GitLab