From 140a10eb3ebd27a2d8aec9b62e30eccabe06ebbc Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Thu, 4 Sep 2025 13:54:07 +0100 Subject: [PATCH] tile: use systemd logging on lowzoom jobs. Add break to retry loops --- cookbooks/tile/recipes/default.rb | 4 +--- cookbooks/tile/templates/default/render-lowzoom.erb | 13 +++++++++---- cookbooks/tile/templates/default/update-lowzoom.erb | 11 ++++++++--- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/cookbooks/tile/recipes/default.rb b/cookbooks/tile/recipes/default.rb index 6bb38a403..f697bc5f4 100644 --- a/cookbooks/tile/recipes/default.rb +++ b/cookbooks/tile/recipes/default.rb @@ -295,8 +295,7 @@ systemd_service "update-lowzoom@" do sandbox true restrict_address_families "AF_UNIX" read_write_paths [ - "/srv/tile.openstreetmap.org/tiles/%i", - "/var/log/tile" + "/srv/tile.openstreetmap.org/tiles/%i" ] restart "on-failure" end @@ -623,7 +622,6 @@ systemd_service "render-lowzoom" do exec_start "/usr/local/bin/render-lowzoom" sandbox true restrict_address_families "AF_UNIX" - read_write_paths "/var/log/tile" end systemd_timer "render-lowzoom" do diff --git a/cookbooks/tile/templates/default/render-lowzoom.erb b/cookbooks/tile/templates/default/render-lowzoom.erb index 9ed8f0fc0..507ee3b92 100644 --- a/cookbooks/tile/templates/default/render-lowzoom.erb +++ b/cookbooks/tile/templates/default/render-lowzoom.erb @@ -2,9 +2,6 @@ # DO NOT EDIT - This file is being maintained by Chef -# Send output to the log -exec > /var/log/tile/render-lowzoom.log 2>&1 - # Get current time timestamp=$(date +%s) <% node[:tile][:styles].each_key do |style| -%> @@ -22,9 +19,17 @@ function update_<%= style %> --min-zoom=0 --max-zoom=12 } -# Loop running the update command until it suceeds +max_tries=120 +count=0 + +# Loop running the update command until it succeeds until update_<%= style %> do + count=$((count + 1)) + if [ "$count" -ge "$max_tries" ]; then + echo "Aborting <%= style %> after $max_tries failed attempts" + break + fi sleep 30 done <% end -%> diff --git a/cookbooks/tile/templates/default/update-lowzoom.erb b/cookbooks/tile/templates/default/update-lowzoom.erb index 7d50f8662..72ed18bfd 100644 --- a/cookbooks/tile/templates/default/update-lowzoom.erb +++ b/cookbooks/tile/templates/default/update-lowzoom.erb @@ -2,9 +2,6 @@ # DO NOT EDIT - This file is being maintained by Chef -# Send output to the log -exec > /var/log/tile/update-lowzoom-<%= @style %>.log 2>&1 - # Define function to update tiles from z0 to z12 for style "<%= @style %>" function update_tiles { @@ -18,9 +15,17 @@ function update_tiles --min-zoom=0 --max-zoom=12 } +max_tries=120 +count=0 + # Loop running the update command until it suceeds until update_tiles do + count=$((count + 1)) + if [ "$count" -ge "$max_tries" ]; then + echo "Aborting <%= @style %> after $max_tries failed attempts" + exit 1 + fi sleep 30 done -- 2.39.5