]> git.openstreetmap.org Git - chef.git/commitdiff
Use a systemd timer to cleanup stale export files
authorTom Hughes <tom@compton.nu>
Sun, 4 Dec 2022 22:39:40 +0000 (22:39 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 4 Dec 2022 22:39:40 +0000 (22:39 +0000)
cookbooks/systemd/resources/service.rb
cookbooks/systemd/templates/default/service.erb
cookbooks/tile/recipes/default.rb
cookbooks/tile/templates/default/export.cron.erb [deleted file]

index 662528c2b81f47e417a08c2fafb83302c92f44aa..1194d4fd6435f1e183cb51274c368dc3fc26ca10 100644 (file)
@@ -29,6 +29,7 @@ property :condition_path_exists_glob, [String, Array]
 property :after, [String, Array]
 property :conflicts, [String, Array]
 property :wants, [String, Array]
+property :joins_namespace_of, [String, Array]
 property :type, String, :is => %w[simple forking oneshot dbus notify idle]
 property :limit_nofile, Integer
 property :limit_as, [Integer, String]
index 1f11ffbf6bdaf1eb2be219f336bba30c81c8c4e8..858dbb3278fe9a2dc7384d540d3dc37c1ef69139 100644 (file)
@@ -19,6 +19,9 @@ Conflicts=<%= Array(@conflicts).join(" ") %>
 <% if @wants -%>
 Wants=<%= Array(@wants).join(" ") %>
 <% end -%>
+<% if @joins_namespace_of -%>
+JoinsNamespaceOf=<%= Array(@joins_namespace_of).join(" ") %>
+<% end -%>
 
 [Service]
 <% if @type -%>
index a9b503c1c6bd3ad1240207356246045a8f5e5882..9d1be80208c4f5c503877db8e0baca5c9bbeec2e 100644 (file)
@@ -187,11 +187,26 @@ template "/srv/tile.openstreetmap.org/cgi-bin/debug" do
   mode "755"
 end
 
-template "/etc/cron.hourly/export" do
-  source "export.cron.erb"
-  owner "root"
-  group "root"
-  mode "755"
+systemd_service "export-cleanup" do
+  description "Cleanup stale export temporary files"
+  joins_namespace_of "apache2.service"
+  exec_start "find /tmp -ignore_readdir_race -name 'export??????' -mmin +60 -delete"
+  user "www-data"
+  sandbox true
+end
+
+systemd_timer "export-cleanup" do
+  description "Cleanup stale export temporary files"
+  on_boot_sec "60m"
+  on_unit_inactive_sec "60m"
+end
+
+service "export-cleanup.timer" do
+  action [:enable, :start]
+end
+
+file "/etc/cron.hourly/export" do
+  action :delete
 end
 
 directory "/srv/tile.openstreetmap.org/data" do
diff --git a/cookbooks/tile/templates/default/export.cron.erb b/cookbooks/tile/templates/default/export.cron.erb
deleted file mode 100644 (file)
index b598e41..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-# DO NOT EDIT - This file is being maintained by Chef
-
-# Removes stale tmp files from the export tab
-exec find /tmp -ignore_readdir_race -name 'export??????' -mmin +60 -delete