From: Grant Slater Date: Tue, 5 Oct 2021 21:30:15 +0000 (+0100) Subject: imagery: enable socket X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/9c080effa5bab5aa01d3c911e32e938123a29787 imagery: enable socket --- diff --git a/cookbooks/imagery/resources/site.rb b/cookbooks/imagery/resources/site.rb index e007e1ae1..11bb8b646 100644 --- a/cookbooks/imagery/resources/site.rb +++ b/cookbooks/imagery/resources/site.rb @@ -100,17 +100,6 @@ action :create do base_domains = [new_resource.site] + Array(new_resource.aliases) tile_domains = base_domains.flat_map { |d| [d, "a.#{d}", "b.#{d}", "c.#{d}"] } - %w[0 1 2 3 4 5 6 7].each do |index| - service "mapserv-fcgi-#{new_resource.site}-#{index}" do - provider Chef::Provider::Service::Systemd - action [:stop, :disable] - end - - systemd_service "mapserv-fcgi-#{new_resource.site}-#{index}" do - action :delete - end - end - systemd_service "mapserv-fcgi-#{new_resource.site}" do description "Map server for #{new_resource.site} layer" environment "MS_MAP_PATTERN" => "^/srv/imagery/mapserver/", @@ -137,6 +126,20 @@ action :create do socket_user "imagery" socket_group "imagery" listen_stream "/run/mapserver-fastcgi/layer-#{new_resource.site}.socket" + + end + + # Ensure service is stopped else socket cannot reload + service "mapserv-fcgi-#{new_resource.site}" do + provider Chef::Provider::Service::Systemd + action :nothing + subscribes :stop, "systemd_service[mapserv-fcgi-#{new_resource.site}]" + subscribes :stop, "systemd_socket[mapserv-fcgi-#{new_resource.site}]" + end + + systemd_unit 'mapserv-fcgi-#{new_resource.site}.socket' do + action [:enable, :start] + subscribes :restart, "systemd_socket[mapserv-fcgi-#{new_resource.site}]" end ssl_certificate new_resource.site do @@ -151,15 +154,13 @@ action :create do end action :delete do - %w[0 1 2 3 4 5 6 7].each do |index| - service "mapserv-fcgi-#{new_resource.site}-#{index}" do - provider Chef::Provider::Service::Systemd - action [:stop, :disable] - end - - systemd_service "mapserv-fcgi-#{new_resource.site}-#{index}" do - action :delete - end + service "mapserv-fcgi-#{new_resource.site}" do + provider Chef::Provider::Service::Systemd + action [:stop, :disable] + end + + systemd_service "mapserv-fcgi-#{new_resource.site}" do + action :delete end nginx_site new_resource.site do diff --git a/cookbooks/imagery/templates/default/nginx_imagery.conf.erb b/cookbooks/imagery/templates/default/nginx_imagery.conf.erb index c123e5aa1..e1d33c7b6 100644 --- a/cookbooks/imagery/templates/default/nginx_imagery.conf.erb +++ b/cookbooks/imagery/templates/default/nginx_imagery.conf.erb @@ -8,7 +8,7 @@ server { } upstream <%= @name %>_fastcgi { - server "unix:/var/run/mapserver-fastcgi/layer-<%= @name %>.socket" max_fails=0 max_conns=4; + 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