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
2 changed files with 102 additions and 19 deletions
|
|
@ -5,7 +5,9 @@
|
|||
# where none is there or the one there is older than PHOTON_REFRESH_DAYS days (30),
|
||||
# unpacked as it comes into /data/next and checked against its MD5 on the way, then
|
||||
# marked ready for serve.sh, which puts it in place. Its archive is never kept: only
|
||||
# the old database and the new one take room at once.
|
||||
# the old database and the new one take room at once. Looked at daily; after a failed
|
||||
# download, again a day later, the wait doubling up to a week while downloads keep
|
||||
# failing.
|
||||
set -eu
|
||||
|
||||
base=https://download1.graphhopper.com/public
|
||||
|
|
@ -21,7 +23,9 @@ fresh() {
|
|||
}
|
||||
|
||||
fetch() {
|
||||
failed=1
|
||||
if [ -e next/ready ] || fresh; then
|
||||
failed=0
|
||||
return 0
|
||||
fi
|
||||
rm -rf next
|
||||
|
|
@ -41,6 +45,7 @@ fetch() {
|
|||
: >next/fetched
|
||||
: >next/ready
|
||||
echo "Photon's database of $region is ready, $(du -sh next/photon_data | cut -f1)."
|
||||
failed=0
|
||||
else
|
||||
wait "$sum" 2>/dev/null || true
|
||||
rm -rf next
|
||||
|
|
@ -48,7 +53,26 @@ fetch() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Seconds to wait after the $1th failed download 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
|
||||
fetch
|
||||
sleep 86400
|
||||
if [ "$failed" -eq 0 ]; then
|
||||
failures=0
|
||||
sleep 86400
|
||||
else
|
||||
failures=$((failures + 1))
|
||||
pause=$(backoff "$failures" 86400 604800)
|
||||
echo "Trying again in $((pause / 3600)) hours." >&2
|
||||
sleep "$pause"
|
||||
fi
|
||||
done
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@
|
|||
# Serves Photon on the database in /data/current (Halkyon Train's ADR 0030, D50), once
|
||||
# data.sh has brought one; and where data.sh has made a newer one (/data/next/ready),
|
||||
# stops Photon, puts the new one in the old one's place and starts it again: a
|
||||
# minute or two without search, once a month. PHOTON_HEAP is Java's heap (6g).
|
||||
# minute or two without search, once a month. Looked at every minute, which also
|
||||
# starts a Photon that stopped (killed for memory) again. PHOTON_HEAP is Java's
|
||||
# heap (6g).
|
||||
set -eu
|
||||
|
||||
cd /data
|
||||
|
|
@ -42,7 +44,7 @@ while [ ! -d current/photon_data ] && ! swap; do
|
|||
done
|
||||
start
|
||||
while :; do
|
||||
sleep 3600 &
|
||||
sleep 60 &
|
||||
wait $! || true
|
||||
if [ -e next/ready ]; then
|
||||
stop
|
||||
|
|
|
|||
Loading…
Reference in a new issue