Skip to content

Commit

Permalink
imagery: restart mapserver every hour to limit memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
Firefishy committed Dec 3, 2024
1 parent c590ff1 commit b173c49
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cookbooks/imagery/resources/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,25 @@
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
Expand Down
1 change: 1 addition & 0 deletions cookbooks/imagery/templates/default/nginx_imagery.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b173c49

Please sign in to comment.