# DO NOT EDIT - This file is being maintained by Chef
-echo $$ > /var/run/render-lowzoom.pid
-<% node[:tile][:styles].each do |name,details| -%>
+# Send output to the log
+exec > /var/log/tile/render-lowzoom.log 2>&1
-project="/srv/tile.openstreetmap.org/styles/<%= name %>/project.mml"
+# Get current time
+timestamp=$(date +%s)
+<% node[:tile][:styles].each_key do |style| -%>
-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
+# Define function to update tiles from z0 to z12 for style "<%= style %>"
+function update_<%= style %>
+{
+ render_old \
+ --timestamp=${timestamp} \
+ --tile-dir=/srv/tile.openstreetmap.org/tiles \
+ --socket=/var/run/renderd/renderd.sock \
+ --num-threads=<%= ( node[:cpu][:total] - 2 ) / 2 %> \
+ --map="<%= style %>" \
+ --max-load=70 \
+ --min-zoom=0 --max-zoom=12
+}
-touch --reference="$project" "/srv/tile.openstreetmap.org/tiles/<%= name %>/planet-import-complete"
+# Loop running the update command until it suceeds
+until update_<%= style %>
+do
+ sleep 30
+done
<% end -%>
-rm -f /var/run/render-lowzoom.pid
-
exit 0