fix(deploy): the sidecars' downloads try again within the hour after a failed round
A failed BRouter segment or listing, a failed tile cut or an unwritable folder waited the whole refresh period, 30 days without routes or a map; they try again after an hour, doubling to a day. Photon's failed download backs off from a day to a week, and a dead Photon is noticed within a minute. The downloads' network is an ordinary bridge the three share, as the comments now say. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
0240a80faf
commit
ba77248930
1 changed files with 102 additions and 19 deletions
|
|
@ -3,7 +3,9 @@
|
|||
# every 5°×5° segment of BRouter's project whose south-west corner lies in
|
||||
# BROUTER_REGION (`west,south,east,north` in whole degrees, multiples of 5; Europe's
|
||||
# `-25,35,40,70` by default), downloaded where the project has a newer one than the
|
||||
# volume holds, then again every BROUTER_REFRESH_DAYS days (30). Each is written beside
|
||||
# volume holds, then again every BROUTER_REFRESH_DAYS days (30); after a round where the
|
||||
# listing or a segment didn't come, again in an hour, the wait doubling up to a day
|
||||
# while rounds keep failing. Each is written beside
|
||||
# its old self and moved over it, so BRouter never reads half a file. Segments of
|
||||
# the sea, which the project doesn't have, are skipped.
|
||||
set -eu
|
||||
|
|
@ -25,8 +27,9 @@ name() {
|
|||
}
|
||||
|
||||
refresh() {
|
||||
complete=0
|
||||
listing=$(curl -fsS "$base/") || { echo "The segments' listing didn't come." >&2; return 0; }
|
||||
fetched=0 kept=0
|
||||
fetched=0 kept=0 failed=0
|
||||
lon=$west
|
||||
while [ "$lon" -le "$east" ]; do
|
||||
lat=$south
|
||||
|
|
@ -36,8 +39,11 @@ refresh() {
|
|||
# Only where the project's is newer than ours (If-Modified-Since): a
|
||||
# current one comes back empty.
|
||||
if [ -e "$file" ]; then set -- -z "$file"; else set --; fi
|
||||
if curl -fsS -R --retry 3 "$@" -o "$file.part" "$base/$file" &&
|
||||
[ -s "$file.part" ]; then
|
||||
if ! curl -fsS -R --retry 3 "$@" -o "$file.part" "$base/$file"; then
|
||||
rm -f "$file.part"
|
||||
echo "Segment $file didn't come." >&2
|
||||
failed=$((failed + 1))
|
||||
elif [ -s "$file.part" ]; then
|
||||
mv "$file.part" "$file"
|
||||
fetched=$((fetched + 1))
|
||||
else
|
||||
|
|
@ -49,10 +55,30 @@ refresh() {
|
|||
done
|
||||
lon=$((lon + 5))
|
||||
done
|
||||
echo "Segments: $fetched fetched, $kept current, $(du -sh . | cut -f1) in all."
|
||||
echo "Segments: $fetched fetched, $kept current, $failed failed, $(du -sh . | cut -f1) in all."
|
||||
if [ "$failed" -eq 0 ]; then complete=1; fi
|
||||
}
|
||||
|
||||
# Seconds to wait after the $1th incomplete round in a row: $2, doubling up to $3.
|
||||
backoff() {
|
||||
pause=$2 n=1
|
||||
while [ "$n" -lt "$1" ] && [ "$pause" -lt "$3" ]; do
|
||||
pause=$((pause * 2)) n=$((n + 1))
|
||||
done
|
||||
if [ "$pause" -gt "$3" ]; then pause=$3; fi
|
||||
echo "$pause"
|
||||
}
|
||||
|
||||
failures=0
|
||||
while :; do
|
||||
refresh
|
||||
sleep $((days * 86400))
|
||||
if [ "$complete" -eq 1 ]; then
|
||||
failures=0
|
||||
sleep $((days * 86400))
|
||||
else
|
||||
failures=$((failures + 1))
|
||||
pause=$(backoff "$failures" 3600 86400)
|
||||
echo "The round wasn't complete; trying again in $((pause / 60)) minutes." >&2
|
||||
sleep "$pause"
|
||||
fi
|
||||
done
|
||||
|
|
|
|||
Loading…
Reference in a new issue