pull time
This commit is contained in:
parent
23ee2bd74a
commit
f40376d239
25
syncloop.sh
25
syncloop.sh
@ -37,10 +37,23 @@ exec {lock_deletes}>>${TMPQUEUEDELETES}
|
|||||||
#acquire lock queue file descriptor
|
#acquire lock queue file descriptor
|
||||||
exec {lock_queue}>>${TMPQUEUEFILE}
|
exec {lock_queue}>>${TMPQUEUEFILE}
|
||||||
|
|
||||||
|
min() {
|
||||||
|
if [ $1 -gt $2 ]; then
|
||||||
|
echo $2
|
||||||
|
else
|
||||||
|
echo $1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
synccycle() {
|
synccycle() {
|
||||||
lastsynctime="$(date -u +%s.%N)"
|
lastsynctime="$(date -u +%s.%N)"
|
||||||
### max waiting time for pull (seconds)
|
### initial max waiting time for pull (seconds) used as unit
|
||||||
maxpulllimit=60
|
pulllimitunit=60
|
||||||
|
pulliteration=1
|
||||||
|
let "maxpulllimit = $pulllimitunit * $pulliteration"
|
||||||
|
echo "inital maxpulllimit: $maxpulllimit"
|
||||||
|
### max waiting time for pull (seconds) 10 min
|
||||||
|
thresholdpulllimit=600
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
if [ -f "$TMPQUEUEFILE" ] || [ -f "$TMPQUEUEDELETES" ]; then
|
if [ -f "$TMPQUEUEFILE" ] || [ -f "$TMPQUEUEDELETES" ]; then
|
||||||
@ -76,19 +89,25 @@ synccycle() {
|
|||||||
cat ${tmpfile} > ${TMPQUEUEFILE}
|
cat ${tmpfile} > ${TMPQUEUEFILE}
|
||||||
rm -f ${tmpfile}
|
rm -f ${tmpfile}
|
||||||
flock -u $lock_queue
|
flock -u $lock_queue
|
||||||
lastsynctime="$(date -u +%s.%N)"
|
#lastsynctime="$(date -u +%s.%N)"
|
||||||
nqueue=$(wc -l < ${TMPQUEUEFILE})
|
nqueue=$(wc -l < ${TMPQUEUEFILE})
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
now="$(date -u +%s.%N)"
|
now="$(date -u +%s.%N)"
|
||||||
elapsed="$(bc <<<"$now-$lastsynctime")"
|
elapsed="$(bc <<<"$now-$lastsynctime")"
|
||||||
|
echo "maxpulllimit: $maxpulllimit"
|
||||||
## if elapsed is greater than maxpulllimit sync from remote with delete option
|
## if elapsed is greater than maxpulllimit sync from remote with delete option
|
||||||
if [ 1 -eq $(echo "$elapsed>$maxpulllimit" | bc) ]; then
|
if [ 1 -eq $(echo "$elapsed>$maxpulllimit" | bc) ]; then
|
||||||
echo 'maxpulllimit reached: sync from remote with --delete option'
|
echo 'maxpulllimit reached: sync from remote with --delete option'
|
||||||
sync $LOCALPATH_HASH $REMOTEPATH $LOCALPATH '--delete'
|
sync $LOCALPATH_HASH $REMOTEPATH $LOCALPATH '--delete'
|
||||||
lastsynctime="$(date -u +%s.%N)"
|
lastsynctime="$(date -u +%s.%N)"
|
||||||
|
## increment the pull iteration
|
||||||
|
let pulliteration++
|
||||||
|
let "limit = $pulliteration * $pulliteration * $pulllimitunit"
|
||||||
|
maxpulllimit=$(min $limit $thresholdpulllimit)
|
||||||
fi
|
fi
|
||||||
|
sleep 10
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user