summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorRaphael Geissert <atomo64@gmail.com>2012-05-01 00:14:06 -0500
committerRaphael Geissert <geissert@debian.org>2012-12-18 18:21:58 -0600
commit361ba6bce1a3fabae9da0ab2b97f2cc7360da1d3 (patch)
treec4b5ac720511f6acb307f321b794d35e2fff1674 /bin
parentdbb0bdd950dccccdd0f9a3d43c656c2a03e4a56a (diff)
Limit the number of update retries
In case something went wrong somewhere and upstream's update stalled or there are stale AUIP files, this will prevent ftpsync from retrying without an eventual error message.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ftpsync19
1 files changed, 15 insertions, 4 deletions
diff --git a/bin/ftpsync b/bin/ftpsync
index c73a0ee..b72b435 100755
--- a/bin/ftpsync
+++ b/bin/ftpsync
@@ -270,6 +270,8 @@ LOCK=${LOCK:-"${TO}/Archive-Update-in-Progress-${MIRRORNAME}"}
LOCKTIMEOUT=${LOCKTIMEOUT:-3600}
# sleeping time when an AUIP file is found but is not ours
UIPSLEEP=${UIPSLEEP:-1200}
+# retries whenever an upstream (or possibly stale) AUIP file is found
+UIPRETRIES=${UIPRETRIES:-3}
# Do we need another rsync run?
UPDATEREQUIRED="${TO}/Archive-Update-Required-${MIRRORNAME}"
# Trace file for mirror stats and checks (make sure we get full hostname)
@@ -447,6 +449,8 @@ fi
export RSYNC_PASSWORD
export RSYNC_PROXY
+UPDATE_RETRIES=0
+
while [ -e "${UPDATEREQUIRED}" ]; do
log "Running mirrorsync, update is required, ${UPDATEREQUIRED} exists"
@@ -506,10 +510,17 @@ while [ -e "${UPDATEREQUIRED}" ]; do
if [ "xtruex" = "x${upstream_uip}x" ]; then
log "Upstream archive update in progress, skipping stage2"
- log "Retrying update in ${UIPSLEEP}"
- touch "${UPDATEREQUIRED}"
- sleep "${UIPSLEEP}"
- result=0
+ if [ ${UPDATE_RETRIES} -lt ${UIPRETRIES} ]; then
+ log "Retrying update in ${UIPSLEEP}"
+ touch "${UPDATEREQUIRED}"
+ UPDATE_RETRIES=$(($UPDATE_RETRIES+1))
+ sleep "${UIPSLEEP}"
+ result=0
+ else
+ error "Update has been retried ${UPDATEREQUIRED} times, aborting"
+ log "Perhaps upstream is still updating or there's a stale AUIP file"
+ result=1
+ fi
else
log "Running stage2: ${RSYNC} ${RSYNC_OPTIONS} ${RSYNC_OPTIONS2} ${EXCLUDE} ${SOURCE_EXCLUDE} ${RSYNCPTH}::${RSYNC_PATH} ${TO}"