From ae900e38585949afe2a0cb3e306ff864da657577 Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Sun, 5 Apr 2020 21:05:26 +0100 Subject: [PATCH] tilecache: add tile_siblings to nginx --- .../tilecache/templates/default/nginx_tile.conf.erb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cookbooks/tilecache/templates/default/nginx_tile.conf.erb b/cookbooks/tilecache/templates/default/nginx_tile.conf.erb index f78bab03d..4527ed502 100644 --- a/cookbooks/tilecache/templates/default/nginx_tile.conf.erb +++ b/cookbooks/tilecache/templates/default/nginx_tile.conf.erb @@ -6,16 +6,19 @@ upstream tile_cache_backend { # Add the other caches to relieve pressure if local squid failing # Balancer: round-robin +<% server_weight = 10 -%> +<% @node[:tilecache][:tile_siblings].each do |cache_peer| -%> <% @caches.each do |cache| -%> +<% if cache_peer == cache[:fqdn] -%> <% if cache[:hostname] != node[:hostname] -%> <% cache.ipaddresses(:family => :inet, :role => :external).sort.each do |address| -%> - server <%= address %>:80 backup; # Server <%= cache[:hostname] %> + server <%= address %>:80 weight=<%= server_weight.div(5) %>; # Server <%= cache[:hostname] %> +<% server_weight += 5 -%> +<% end -%> +<% end -%> <% end -%> <% end -%> <% end -%> - - keepalive 512; - keepalive_requests 1024; } # Geo Map of tile caches -- 2.43.2