5 # Copyright:: 2021, 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 # https://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 include_recipe "accounts"
21 include_recipe "munin"
22 include_recipe "apache"
25 basedir = data_bag_item("accounts", username)["home"]
27 %w[bin site diffs db src].each do |dirname|
28 directory "#{basedir}/#{dirname}" do
36 ## Install overpass from source
38 srcdir = "#{basedir}/src/osm-3s_v#{node[:overpass][:version]}"
49 remote_file "#{srcdir}.tar.gz" do
51 source "https://dev.overpass-api.de/releases/osm-3s_v#{node[:overpass][:version]}.tar.gz"
57 execute "source_tarball" do
59 command "tar -xf #{srcdir}.tar.gz"
61 notifies :run, "execute[install_overpass]"
62 not_if { ::File.exist?(srcdir) }
65 execute "install_overpass" do
69 command "./configure --enable-lz4 --prefix=#{basedir} && make install"
74 ssl_certificate node[:fqdn] do
76 node[:overpass][:fqdn]]
77 notifies :reload, "service[apache2]"
81 apache_module "headers"
83 apache_site "#{node[:overpass][:fqdn]}" do
85 directory "#{basedir}/site"
86 variables :script_directory => "#{basedir}/cgi-bin"
97 logdir = node[:overpass][:logdir]
106 %w[overpass-update-db overpass-update-areas].each do |fname|
107 template "#{basedir}/bin/#{fname}" do
108 source "#{fname}.erb"
112 variables :basedir => basedir, :srcdir => srcdir
116 template "#{basedir}/bin/overpass-import-db" do
117 source "overpass-import-db.erb"
121 variables :basedir => basedir, :username => username, :srcdir => srcdir
124 systemd_service "overpass-dispatcher" do
125 description "Overpass Main Dispatcher"
126 working_directory basedir
127 exec_start "#{basedir}/bin/dispatcher --osm-base #{meta_map_short[node[:overpass][:meta_mode]]} --db-dir=#{basedir}/db --rate-limit=#{node[:overpass][:rate_limit]} --space=#{node[:overpass][:dispatcher_space]}"
128 exec_stop "#{basedir}/bin/dispatcher --osm-base --terminate"
129 standard_output "append:#{logdir}/osm_base.log"
133 service "overpass-dispatcher" do
137 systemd_service "overpass-area-dispatcher" do
138 description "Overpass Area Dispatcher"
139 after ["overpass-dispatcher"]
140 working_directory basedir
141 exec_start "#{basedir}/bin/dispatcher --areas #{meta_map_short[node[:overpass][:meta_mode]]} --db-dir=#{basedir}/db"
142 exec_stop "#{basedir}/bin/dispatcher --areas --terminate"
143 standard_output "append:#{logdir}/areas.log"
147 service "overpass-area-dispatcher" do
151 systemd_service "overpass-update" do
152 description "Overpass Update Application"
153 after ["overpass-dispatcher"]
154 working_directory basedir
155 exec_start "#{basedir}/bin/overpass-update-db"
156 standard_output "append:#{logdir}/update.log"
160 if node[:overpass][:meta_mode] == "attic"
161 systemd_service "overpass-area-processor" do
162 description "Overpass Area Processor"
163 after ["overpass-area-dispatcher"]
164 working_directory basedir
165 exec_start "#{basedir}/bin/overpass-update-areas"
166 standard_output "append:#{logdir}/area-processor.log"
171 systemd_service "overpass-area-processor" do
172 description "Overpass Area Processor"
173 after ["overpass-area-dispatcher"]
174 working_directory basedir
175 exec_start "#{basedir}/bin/osm3s_query --progress --rules"
176 standard_input "file:#{srcdir}/rules/areas.osm3s"
177 standard_output "append:#{logdir}/area-processor.log"
183 systemd_timer "overpass-area-processor" do
184 description "Update areas in Overpass"
185 on_calendar "*-*-* *:*:00"
188 service "overpass-area-processor" do