]> git.openstreetmap.org Git - chef.git/commitdiff
Imagery - nginx layer fragments
authorGrant Slater <git@firefishy.com>
Sun, 31 Jan 2016 15:22:36 +0000 (15:22 +0000)
committerGrant Slater <git@firefishy.com>
Sun, 31 Jan 2016 16:48:19 +0000 (16:48 +0000)
cookbooks/imagery/resources/layer.rb
cookbooks/imagery/templates/default/nginx_imagery.conf.erb
cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb [new file with mode: 0644]

index dddd665221ec4bbc1cd17a1f93834447afa81093..648ac06d607f7f8ca41f74d3601682ec523a0779 100644 (file)
@@ -59,4 +59,43 @@ action :create do
     subscribes :restart, "template[/srv/imagery/mapserver/layer-#{name}.map]"
     subscribes :restart, "template[/etc/init/mapserv-fgi-layer-#{name}.conf]"
   end
+
+  directory "/srv/imagery/nginx/#{site}" do
+    owner "root"
+    group "root"
+    mode 0755
+    recursive true
+  end
+
+  template "/srv/imagery/nginx/#{site}/layer-#{name}.conf" do
+    cookbook "imagery"
+    source "nginx_imagery_layer_fragment.conf.erb"
+    owner "root"
+    group "root"
+    mode 0644
+    variables new_resource.to_hash
+    notifies :reload, "service[nginx]", :delayed
+  end
+
+end
+
+action :delete do
+  service "mapserv-fgi-layer-#{name}.conf" do
+    provider Chef::Provider::Service::Upstart
+    action [:stop, :disable]
+    supports :status => true, :restart => true, :reload => false
+  end
+
+  file "/srv/imagery/mapserver/layer-#{name}.map" do
+    action :delete
+  end
+
+  file "/etc/init/mapserv-fgi-layer-#{name}.conf" do
+    action :delete
+  end
+
+  file "/srv/imagery/nginx/#{site}/layer-#{name}.conf" do
+    action :delete
+    notifies :reload, "service[nginx]", :delayed
+  end
 end
index 5b3b91eb4296f8be3cc1d23d9b71ee49c1142c41..5158aba7367788d0dc0d368a79223f3ca5b3f064 100644 (file)
@@ -2,7 +2,6 @@ server {
     listen       80;
     server_name  <%= @name %>;
 
-    #FIXME WIP
-    #Needs to include or iterate through layers with rewrite + fastcgi
-    #Git checkout of web?
+    include /srv/imagery/nginx/<%= @name %>/layer-*.conf
+
 }
diff --git a/cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb b/cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb
new file mode 100644 (file)
index 0000000..f5d687f
--- /dev/null
@@ -0,0 +1,8 @@
+# DO NOT EDIT - This file is being maintained by Chef
+
+location ~* "^/layer/<%= @name %>/(\d+)/(\d+)/(\d+)\.(png|jpg|jpeg)$" {
+  fastcgi_param  QUERY_STRING "map=/srv/imagery/<%= @name %>.map&mode=tile&layers=<%= @name %>&tilemode=gmap&tile=$2+$3+$1";
+  fastcgi_pass "unix:/var/run/mapserver-fastcgi/layer-<%= @name %>.socket";
+  include fastcgi_params;
+  gzip off;
+}