From bfe0c75e6235b718884135d8c450d2b171f1fbd4 Mon Sep 17 00:00:00 2001 From: mixmix Date: Thu, 24 Oct 2024 13:50:09 +1300 Subject: [PATCH] retry docker verbose if fail --- dev/bin/remove-db.sh | 4 ++-- dev/bin/spin-down.sh | 17 ++++++++++++++--- dev/bin/spin-up.sh | 19 +++++++++++++++---- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/dev/bin/remove-db.sh b/dev/bin/remove-db.sh index 48c6728b..87c91c53 100755 --- a/dev/bin/remove-db.sh +++ b/dev/bin/remove-db.sh @@ -1,5 +1,5 @@ #! /usr/bin/env bash rm -rf .entropy -docker compose --file dev/docker-scripts/four-nodes.yaml --progress quiet down -docker compose --file dev/docker-scripts/one-node-no-tss.yaml --progress quiet down +./dev/bin/spin-down.sh four-nodes +./dev/bin/spin-down.sh one-node-no-tss diff --git a/dev/bin/spin-down.sh b/dev/bin/spin-down.sh index 181778ef..1ef6b978 100755 --- a/dev/bin/spin-down.sh +++ b/dev/bin/spin-down.sh @@ -1,6 +1,17 @@ #! /usr/bin/env bash source ./dev/bin/ENTROPY_CORE_VERSION.sh -docker_file=./dev/docker-scripts/$1.yaml -docker compose --file $docker_file --progress quiet down -docker compose --file $docker_file logs +FILE="dev/docker-scripts/$1.yaml" + +spin_down() { + docker compose --file "$FILE" "$@" down + + if [ $? -ne 0 ]; then + echo "Error: 'docker compose down' failed." + echo "Retrying verbose:" + docker compose --file "$FILE" down + fi +} + +spin_down --progress quiet +docker compose --file $FILE logs diff --git a/dev/bin/spin-up.sh b/dev/bin/spin-up.sh index 29358f3e..31b7da08 100755 --- a/dev/bin/spin-up.sh +++ b/dev/bin/spin-up.sh @@ -1,9 +1,20 @@ #! /usr/bin/env bash source ./dev/bin/ENTROPY_CORE_VERSION.sh -docker_file=dev/docker-scripts/$1.yaml -if [ $GITHUB_WORKSPACE ]; then - docker compose --file $docker_file up --detach --quiet-pull; +FILE="dev/docker-scripts/$1.yaml" + +spin_up() { + docker compose --file "$FILE" "$@" up --detach + + if [ $? -ne 0 ]; then + echo "Error: 'docker compose up' failed." + echo "Retrying verbose:" + docker compose --file "$FILE" up --detach + fi +} + +if [ -n "$GITHUB_WORKSPACE" ]; then + spin_up --progress quiet --quiet-pull else - docker compose --file $docker_file --progress quiet up --detach; + spin_up --progress quiet fi