Skip to content

Commit

Permalink
Retry downloads up to three times during bootstrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
dzuelke committed Aug 16, 2016
1 parent bdcdd59 commit 8b2a3cb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
- ext-phalcon/2.0.13 [David Zuelke]
- ext-phalcon/3.0.0 [David Zuelke]

### CHG

- Retry downloads up to three times during bootstrapping [David Zuelke]

## v109 (2016-07-21)

### ADD
Expand Down
12 changes: 10 additions & 2 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,16 @@ fi
# minimal PHP needed for installs, and make "composer" invocations use that for now
mkdir -p $build_dir/.heroku/php-min
ln -s $build_dir/.heroku/php-min /app/.heroku/php-min
curl --silent --location "${s3_url}php-min-7.0.9.tar.gz" | tar xz -C $build_dir/.heroku/php-min
curl --silent --location "${s3_url}composer-1.1.3.tar.gz" | tar xz -C $build_dir/.heroku/php

curl_retry_on_18 --silent --location -o $build_dir/.heroku/php-min.tar.gz "${s3_url}php-min-7.0.9.tar.gz" || error "Failed to download minimal PHP for bootstrapping.
Please try again, or contact support if this problem persists."
tar xzf $build_dir/.heroku/php-min.tar.gz -C $build_dir/.heroku/php-min
rm $build_dir/.heroku/php-min.tar.gz

curl_retry_on_18 --silent --location -o $build_dir/.heroku/composer.tar.gz "${s3_url}composer-1.1.3.tar.gz" || error "Failed to download Composer. Please try again, or contact support if this problem persists."
tar xzf $build_dir/.heroku/composer.tar.gz -C $build_dir/.heroku/php
rm $build_dir/.heroku/composer.tar.gz

# this alias is just for now while we install platform packages
composer() {
/app/.heroku/php-min/bin/php /app/.heroku/php/bin/composer "$@"
Expand Down
13 changes: 12 additions & 1 deletion bin/util/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,15 @@ export_env_dir() {
:
done
fi
}
}

curl_retry_on_18() {
local ec=18;
local attempts=0;
while [[ $ec -eq 18 && $attempts -lt 3 ]]; do
((attempts++))
curl "$@" # -C - would return code 33 if unsupported by server
ec=$?
done
return $ec
}

0 comments on commit 8b2a3cb

Please sign in to comment.