From 4f02d7866709d630d9e1ff09319507a1247d3d3e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 25 May 2017 15:42:56 +0200 Subject: Set network timeouts for curl, bpkg --- buildos | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'buildos') diff --git a/buildos b/buildos index 0845ed1..c1e6f7e 100755 --- a/buildos +++ b/buildos @@ -29,6 +29,13 @@ function error () exit 1 } +# Network timeouts: 30 seconds to connect, 10 minutes to complete. Note that +# the toolchain archives can be quite sizable. +# +curl=(curl -f -L -s -S --connect-timeout 30 --max-time 600) +bpkg=(bpkg --fetch curl --fetch-option --connect-timeout --fetch-option 30 \ + --fetch-option --max-time --fetch-option 600) + info "starting build os monitor..." # Parse the kernel command line. This is complicated by the fact that the @@ -529,7 +536,7 @@ function toolchain_fetch () # # info "fetching $u [$l]" - if ! curl -f -L -s -S -o "$tr/$f" "$u"; then + if ! "${curl[@]}" -o "$tr/$f" "$u"; then info "unable to fetch $u" return 1 fi @@ -659,7 +666,7 @@ function bbot_check () # l_stat="$(bpkg status libbbot)" b_stat="$(bpkg status bbot)" - if ! bpkg fetch -q; then + if ! "${bpkg[@]}" fetch -q; then info "failed to fetch package information" break fi @@ -736,8 +743,8 @@ function bbot_start () # # Build and install the bbot agent. # - if ! bpkg build --build-option --jobs --build-option "$cpu_slice" \ - --yes libbbot bbot; then + if ! "${bpkg[@]}" --build-option --jobs --build-option "$cpu_slice" \ + build --yes libbbot bbot; then info "failed to build bbot-agent@$tn" break fi @@ -855,7 +862,7 @@ while true; do f="$p" fi - if curl -f -L -s -S -o "$f" "$tu"; then + if "${curl[@]}" -o "$f" "$tu"; then # Take care of change detection. # @@ -1096,7 +1103,7 @@ EOF # Fetch the current id. While normally it will be a TFTP URL, it could also # be HTTP(S) so we configure sensible behavior for that. # - if id="$(curl -f -L -s -S "$buildid_url")"; then + if id="$("${curl[@]}" "$buildid_url")"; then if [ "$id" != "$buildid" ]; then email "rebooting because of new os build" <