2 # Cookbook Name:: imagery
3 # Resource:: imagery_layer
5 # Copyright 2016, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
20 default_action :create
22 property :layer, String, :name_property => true
23 property :site, String, :required => true
24 property :source, String, :required => true
25 property :root_layer, [TrueClass, FalseClass], :default => false
26 property :text, String
27 property :copyright, String, :default => "Copyright"
28 property :projection, String, :default => "EPSG:3857"
29 property :palette, String
30 property :extent, String
31 property :background_colour, String
32 property :resample, String, :default => "average"
33 property :imagemode, String
34 property :extension, String, :default => "png"
35 property :max_zoom, Fixnum, :default => 23
36 property :url_aliases, [String, Array], :default => []
37 property :revision, Fixnum, :default => 1
40 template "/srv/imagery/mapserver/layer-#{layer}.map" do
42 source "mapserver.map.erb"
46 variables new_resource.to_hash
49 systemd_service "mapserv-fcgi-#{layer}" do
50 description "Map server for #{layer} layer"
52 environment "MS_MAPFILE" => "/srv/imagery/mapserver/layer-#{layer}.map",
53 "MS_MAP_PATTERN" => "^/srv/imagery/mapserver/",
54 "MS_ERRORFILE" => "/tmp/mapserver-layer-#{layer}.log",
55 "MS_DEBUGLEVEL" => "1"
58 exec_start "/usr/bin/spawn-fcgi -n -s /run/mapserver-fastcgi/layer-#{layer}.socket -M 0666 -- /usr/bin/multiwatch -f 4 -- /usr/lib/cgi-bin/mapserv"
62 service "mapserv-fcgi-#{layer}" do
63 action [:enable, :start]
64 subscribes :restart, "template[/srv/imagery/mapserver/layer-#{layer}.map]"
65 subscribes :restart, "systemd_service[mapserv-fcgi]"
68 directory "/srv/imagery/nginx/#{site}" do
75 template "/srv/imagery/nginx/#{site}/layer-#{layer}.conf" do
77 source "nginx_imagery_layer_fragment.conf.erb"
81 variables new_resource.to_hash
86 service "mapserv-fcgi-layer-#{layer}" do
87 action [:stop, :disable]
90 file "/srv/imagery/mapserver/layer-#{layer}.map" do
94 systemd_service "mapserv-fcgi-#{layer}" do
98 file "/srv/imagery/nginx/#{site}/layer-#{layer}.conf" do
104 notifies :restart, "service[nginx]"