Skip to content

Commit

Permalink
Run osm2pgsql replication in a loop instead of relying on Restart=always
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Nov 23, 2023
1 parent 5d6af18 commit 73471b4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cookbooks/tile/recipes/default.rb
Expand Up @@ -543,7 +543,7 @@
end

template "/usr/local/bin/replicate" do
source "replicate.erb"
source "replicate-custom.erb"
owner "root"
group "root"
mode "755"
Expand Down Expand Up @@ -609,6 +609,13 @@
mode "775"
end

template "/usr/local/bin/replicate" do
source "replicate-osm2pgsql.erb"
owner "root"
group "root"
mode "755"
end

systemd_service "expire-tiles" do
description "Tile dirtying service"
type "simple"
Expand Down Expand Up @@ -655,19 +662,19 @@
after "postgresql.service"
wants "postgresql.service"
user "tile"
exec_start "/bin/osm2pgsql-replication update --database gis --post-processing /usr/local/bin/replicate-post -- #{osm2pgsql_arguments.join(' ')}"
exec_start "/usr/local/bin/replicate"
sandbox :enable_network => true
restrict_address_families "AF_UNIX"
read_write_paths [
"/store/database/nodes",
"/var/lib/replicate"
]
restart "always"
restart_sec 30
restart "on-failure"
end

service "replicate" do
action [:enable, :start]
subscribes :restart, "template[/usr/local/bin/replicate]"
subscribes :restart, "systemd_service[replicate]"
end
end
Expand Down
26 changes: 26 additions & 0 deletions cookbooks/tile/templates/default/replicate-osm2pgsql.erb
@@ -0,0 +1,26 @@
#!/bin/sh

# DO NOT EDIT - This file is being maintained by Chef

while [ 1 = 1 ]
do
/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 \
<% 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 -%>

sleep 30
done

0 comments on commit 73471b4

Please sign in to comment.