X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/0f9b10e62eb9048bfcfa512500adb865ebc1ea79..9694d64a67dca98ce1d574852e7114daaff4727f:/cookbooks/overpass/templates/default/overpass-update-db.erb diff --git a/cookbooks/overpass/templates/default/overpass-update-db.erb b/cookbooks/overpass/templates/default/overpass-update-db.erb index 5ac8d1570..09b8648fb 100644 --- a/cookbooks/overpass/templates/default/overpass-update-db.erb +++ b/cookbooks/overpass/templates/default/overpass-update-db.erb @@ -13,35 +13,33 @@ META=--keep-attic META= <% end -%> -while true; do - status=3 # make it sleep on issues +status=3 # make it sleep on issues - if [ -f <%= @basedir %>/db/replicate-id ]; then - # first apply any pending updates - if [ -f <%= @basedir %>/diffs/latest.osc ]; then - DATA_VERSION=`osmium fileinfo -e -g data.timestamp.last <%= @basedir %>/diffs/latest.osc` - if [ "x$DATA_VERSION" != "x" ]; then - echo "Downloaded up to timestamp $DATA_VERSION" - while ! <%= @basedir %>/bin/update_from_dir --osc-dir=<%= @basedir %>/diffs --version=$DATA_VERSION $META --flush-size=0; do - echo "Error while updating. Retry in 1 min." - sleep 60 - done - fi - rm <%= @basedir %>/diffs/latest.osc +if [ -f <%= @basedir %>/db/replicate-id ]; then + # first apply any pending updates + if [ -f <%= @basedir %>/diffs/latest.osc ]; then + DATA_VERSION=`osmium fileinfo -e -g data.timestamp.last <%= @basedir %>/diffs/latest.osc` + if [ "x$DATA_VERSION" != "x" ]; then + echo "Downloaded up to timestamp $DATA_VERSION" + while ! <%= @basedir %>/bin/update_from_dir --osc-dir=<%= @basedir %>/diffs --version=$DATA_VERSION $META --flush-size=0; do + echo "Error while updating. Retry in 1 min." + sleep 60 + done fi - - $PYOSMIUM -v -s 1000 -o <%= @basedir %>/diffs/latest.osc - status=$? - fi - - if [ $status -eq 0 ]; then - echo "Downloaded next batch." - elif [ $status -eq 3 ]; then rm <%= @basedir %>/diffs/latest.osc - echo "No new data, sleeping for a minute." - sleep 60 - else - echo "Fatal error, stopping updates." - exit $status fi -done + + $PYOSMIUM -v -s 1000 -o <%= @basedir %>/diffs/latest.osc + status=$? +fi + +if [ $status -eq 0 ]; then + echo "Downloaded next batch." +elif [ $status -eq 3 ]; then + rm <%= @basedir %>/diffs/latest.osc + echo "No new data, sleeping for a minute." + sleep 60 +else + echo "Fatal error, stopping updates." + exit $status +fi