X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/ddb1840147187f05afa60aba2ca861b62443dac6..1bc8da5f3a3bfd6c3f0ba374f12d489d13831460:/cookbooks/tile/templates/default/replicate.erb?ds=sidebyside diff --git a/cookbooks/tile/templates/default/replicate.erb b/cookbooks/tile/templates/default/replicate.erb index 24e418198..531adca83 100644 --- a/cookbooks/tile/templates/default/replicate.erb +++ b/cookbooks/tile/templates/default/replicate.erb @@ -1,94 +1,26 @@ -#!/bin/bash +#!/bin/sh # DO NOT EDIT - This file is being maintained by Chef -# Initialize timestamp with day of latest planet dump -# Setting to midnight ensures we get conistent data after first run -# osmosis --read-replication-interval-init - -# Define exit handler -function onexit { - [ -f state-prev.txt ] && mv state-prev.txt state.txt -} - -# Send output to the log -exec > /var/log/tile/replicate.log 2>&1 - -# Change to the replication state directory -cd /var/lib/replicate - -# Install exit handler -trap onexit EXIT - -# Read in initial state -. state.txt - -# Loop indefinitely -while true +while [ 1 = 1 ] do - # Work out the name of the next file - file="changes-${sequenceNumber}.osm.gz" - - # Save state file so we can rollback if an error occurs - cp state.txt state-prev.txt - - # Fetch the next set of changes - osmosis --read-replication-interval --simc --write-xml-change file="${file}" compressionMethod="gzip" - - # Check for errors - if [ $? -eq 0 ] - then - # Enable exit on error - set -e - - # Remember the previous sequence number - prevSequenceNumber=$sequenceNumber - - # Read in new state - . state.txt - - # Did we get any new data? - if [ "${sequenceNumber}" == "${prevSequenceNumber}" ] - then - # Log the lack of data - echo "No new data available. Sleeping..." - - # Remove file, it will just be an empty changeset - rm ${file} - - # No need to rollback now - rm state-prev.txt - - # Sleep for a short while - sleep 30 - else - # Log the new data - echo "Fetched new data from ${prevSequenceNumber} to ${sequenceNumber} into ${file}" - - # Apply the changes to the database -<% if node[:tile][:node_file] -%> - osm2pgsql --slim --append --flat-nodes=<%= node[:tile][:node_file] %> ${file} -<% else -%> - osm2pgsql --slim --append ${file} + /bin/osm2pgsql-replication update \ + --database gis \ + --post-processing /usr/local/bin/replicate-post \ + -- \ + --number-processes=1 \ + --log-progress=false \ + --expire-tiles=10-16 \ + --expire-output=/var/lib/replicate/dirty-tiles.txt \ +<% if node[:tile][:database][:multi_geometry] -%> + --multi-geometry \ +<% end -%> +<% if node[:tile][:database][:hstore] -%> + --hstore \ +<% end -%> +<% if node[:tile][:database][:tag_transform_script] -%> + --tag-transform-script=<%= node[:tile][:database][:tag_transform_script] %> <% end -%> - # No need to rollback now - rm state-prev.txt - - # Expire tiles which are touched by the changes - sudo -u www-data /usr/local/bin/expire-tiles ${file} > /dev/null 2>&1 & - fi - - # Delete old downloads - find . -name 'changes-*.gz' -mmin +300 -exec rm -f {} \; - - # Disable exit on error - set +e - else - # Log our failure to fetch changes - echo "Failed to fetch changes - waiting a few minutes before retry" - - # Wait five minutes and have another go - sleep 300 - fi + sleep 30 done