- # Work out the name of the next file
- file="changes-${sequenceNumber}.osc.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
- osm2pgsql --database gis --slim --append --number-processes=1 \
-<% if node[:tile][:node_file] -%>
- --flat-nodes=<%= node[:tile][:node_file] %> \
+ /bin/osm2pgsql-replication update \
+ --database gis \
+ --post-processing /usr/local/bin/replicate-post \
+ -- \
+ --number-processes=1 \
+ --log-progress=false \
+ --expire-tiles=13-19 \
+ --expire-output=/var/lib/replicate/dirty-tiles.txt \
+<% if node[:tile][:database][:multi_geometry] -%>
+ --multi-geometry \