When a style changes rerender zooms 0-10 before updating the timestamp
authorTom Hughes <tom@compton.nu>
Thu, 20 Jun 2013 21:32:57 +0000 (22:32 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 20 Jun 2013 21:38:20 +0000 (22:38 +0100)
cookbooks/tile/recipes/default.rb
cookbooks/tile/templates/default/render-lowzoom.erb [new file with mode: 0644]
cookbooks/tile/templates/default/render-lowzoom.init.erb [new file with mode: 0644]

index 7b24c5c..09eb9f5 100644 (file)
@@ -182,6 +182,25 @@ node[:tile][:data].each do |name,data|
   end
 end
 
+template "/usr/local/bin/render-lowzoom" do
+  source "render-lowzoom.erb"
+  owner "root"
+  group "root"
+  mode 0755
+end
+
+template "/etc/init.d/render-lowzoom" do
+  source "render-lowzoom.init.erb"
+  owner "root"
+  group "root"
+  mode 0755
+end
+
+service "render-lowzoom" do
+  action :disable
+  supports :restart => true
+end
+
 nodejs_package "carto"
 nodejs_package "millstone"
 
@@ -217,16 +236,14 @@ node[:tile][:styles].each do |name,details|
   end
 
   execute "#{style_directory}/project.mml" do
+    action :nothing
     command "carto project.mml > project.xml"
     cwd style_directory
     user "tile"
     group "tile"
-    not_if do
-      File.exist?("#{style_directory}/project.xml") and
-      File.mtime("#{style_directory}/project.xml") >= File.mtime("#{style_directory}/project.mml")
-    end
-    notifies :touch, "file[#{tile_directory}/planet-import-complete]"
+    subscribes :run, "git[#{style_directory}]"
     notifies :restart, "service[renderd]"
+    notifies :restart, "service[render-lowzoom]"
   end
 end
 
diff --git a/cookbooks/tile/templates/default/render-lowzoom.erb b/cookbooks/tile/templates/default/render-lowzoom.erb
new file mode 100644 (file)
index 0000000..a87dc38
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+echo $$ > /var/run/render-lowzoom.pid
+<% node[:tile][:styles].each do |name,details| -%>
+
+project="/srv/tile.openstreetmap.org/styles/<%= name %>/project.mml"
+
+render_old \
+  --config=/etc/renderd.conf \
+  --tile-dir=/srv/tile.openstreetmap.org/tiles \
+  --socket=/var/run/renderd/renderd.sock \
+  --num-threads=<%= ( node[:cpu][:total] - 2 ) / 4 %> \
+  --map="<%= name %>" \
+  --timestamp=$(stat --printf=%Y ${project}) \
+  --min-zoom=0 --max-zoom=10
+
+touch --reference="$project" "/srv/tile.openstreetmap.org/tiles/<%= name %>/planet-import-complete"
+<% end -%>
+
+rm -f /var/run/render-lowzoom.pid
+
+exit 0
diff --git a/cookbooks/tile/templates/default/render-lowzoom.init.erb b/cookbooks/tile/templates/default/render-lowzoom.init.erb
new file mode 100644 (file)
index 0000000..986ce88
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+start() {
+  start-stop-daemon --start --chuid tile --background --make-pidfile -pidfile /var/run/render-lowzoom.pid --exec /usr/local/bin/render-lowzoom
+}
+
+stop() {
+  start-stop-daemon --stop --retry 300 --pidfile /var/run/render-lowzoom.pid --exec /usr/local/bin/render-lowzoom
+}
+
+case "$1" in
+  start)
+    start
+    ;;
+  stop)
+    stop
+    ;;
+  restart)
+    stop
+    start
+    ;;
+esac