X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/3b563e12600d3519011cde414ee0465698a7814f..35184d77a1a09c3028dbe1cbaf6e20fd2be69859:/cookbooks/overpass/templates/default/overpass-update-db.erb?ds=sidebyside 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