X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/2bfb0ef07fb64314f5c4ded641a8c280df9c1d0b..e92ed5e09215d67f2bd7dc21a32425d7ec5aa26f:/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..ea6e390a3 100644 --- a/cookbooks/overpass/templates/default/overpass-update-db.erb +++ b/cookbooks/overpass/templates/default/overpass-update-db.erb @@ -1,6 +1,6 @@ #!/bin/bash -PYOSMIUM="pyosmium-get-changes --server <%= node[:overpass][:replication_url] %> -f <%= @basedir %>/db/replicate-id" +PYOSMIUM="pyosmium-get-changes --server <%= node[:overpass][:replication_url] %> --diff-type osc.gz -f <%= @basedir %>/db/replicate-id" <% if node[:overpass][:meta_mode] == "attic" -%> PYOSMIUM="$PYOSMIUM --no-deduplicate" <% end -%> @@ -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