]> git.openstreetmap.org Git - chef.git/commitdiff
imagery: restart mapserver every hour to limit memory leak
authorGrant Slater <github@firefishy.com>
Tue, 3 Dec 2024 13:20:13 +0000 (13:20 +0000)
committerGrant Slater <github@firefishy.com>
Tue, 3 Dec 2024 13:20:13 +0000 (13:20 +0000)
cookbooks/imagery/resources/site.rb
cookbooks/imagery/templates/default/nginx_imagery.conf.erb

index 856159be9b80c4efa1914253c069f564dfe066e0..23771a4fcfd4409d42b485d731051f51fa540b76 100644 (file)
@@ -139,6 +139,25 @@ action :create do
     not_if { new_resource.uses_tiler }
   end
 
+  # mapserver leaks memory, so restart it regularly. It is activated automatically by socket
+  systemd_service "mapserv-fcgi-#{new_resource.site}-stop" do
+    type "simple"
+    user "root"
+    exec_start "/bin/systemctl --quiet stop mapserv-fcgi-#{new_resource.site}.service"
+    sandbox true
+    restrict_address_families "AF_UNIX"
+  end
+
+  systemd_timer "mapserv-fcgi-#{new_resource.site}-stop" do
+    on_boot_sec "10m"
+    on_unit_inactive_sec "1h"
+    randomized_delay_sec "10m"
+  end
+
+  service "mapserv-fcgi-#{new_resource.site}-stop.timer" do
+    action [:enable, :start]
+  end
+
   ssl_certificate new_resource.site do
     domains tile_domains
   end
index 42ae9ac014b3a10b609adec40e0f1504fdb8e0cb..03a439343b57bb7b3dac7bb1855687901f5b5a9d 100644 (file)
@@ -15,6 +15,7 @@ upstream <%= @name %>_tiler_backend {
 <% else -%>
 upstream <%= @name %>_fastcgi {
     server "unix:/var/run/mapserver-fastcgi/layer-<%= @name %>.socket" max_fails=0;
+    server "unix:/var/run/./mapserver-fastcgi/layer-<%= @name %>.socket" max_fails=0;
 
     # Use default round-robin to distribute requests, rather than pick "fast" but maybe faulty.
     # Do not use keepalive