Skip to content

Commit

Permalink
Retry failing zeroconf scripts for Pharo
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Dec 10, 2023
1 parent 8fb2e2a commit 3f608f0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,24 @@ deploy() {
fold_end deploy
}

retry() {
local retries=$1
local command=$2
local status=0

$command || status=$?

if [[ $status -ne 0 ]]; then
if [[ $retries -gt 0 ]]; then
echo "Retrying in one second..."
sleep 1
retry $(($retries - 1)) "$command"
else
print_error_and_exit "The command '${command}' failed too often (last exit code: ${status})."
fi
fi
}


################################################################################
# Travis-related helper functions (based on https://git.io/vzcTj).
Expand Down
4 changes: 2 additions & 2 deletions pharo/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ pharo::prepare_vm() {
pushd "${config_vm_dir}" > /dev/null
fold_start download_vm "Downloading ${smalltalk_name} vm..."
download_file "${pharo_vm_url}" "${pharo_zeroconf}"
bash "${pharo_zeroconf}"
retry 3 "bash ${pharo_zeroconf}"
fold_end download_vm
popd > /dev/null
fi
Expand Down Expand Up @@ -283,7 +283,7 @@ pharo::prepare_image() {
pushd "${target}" > /dev/null
fold_start download_image "Downloading ${smalltalk_name} image..."
download_file "${pharo_image_url}" "${pharo_zeroconf}"
bash "${pharo_zeroconf}"
retry 3 "bash ${pharo_zeroconf}"
fold_end download_image
popd > /dev/null
fi
Expand Down

0 comments on commit 3f608f0

Please sign in to comment.