]> git.openstreetmap.org Git - chef.git/commitdiff
tilecache: add tile_siblings to nginx
authorGrant Slater <git@firefishy.com>
Sun, 5 Apr 2020 20:05:26 +0000 (21:05 +0100)
committerGrant Slater <git@firefishy.com>
Sun, 5 Apr 2020 20:05:26 +0000 (21:05 +0100)
cookbooks/tilecache/templates/default/nginx_tile.conf.erb

index f78bab03d1a81d4556b20e8d8892741c476eec40..4527ed5022eaaf9e770e4e69f63785b1973121ff 100644 (file)
@@ -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