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 "default" do
87 apache_site "#{node[:overpass][:fqdn]}" do
89 directory "#{basedir}/site"
90 variables :script_directory => "#{basedir}/cgi-bin"
101 logdir = node[:overpass][:logdir]
110 %w[overpass-update-db overpass-update-areas].each do |fname|
111 template "#{basedir}/bin/#{fname}" do
112 source "#{fname}.erb"
116 variables :basedir => basedir, :srcdir => srcdir
120 template "#{basedir}/bin/overpass-import-db" do
121 source "overpass-import-db.erb"
125 variables :basedir => basedir, :username => username, :srcdir => srcdir
128 systemd_service "overpass-dispatcher" do
129 description "Overpass Main Dispatcher"
130 working_directory basedir
131 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]}"
132 exec_stop "#{basedir}/bin/dispatcher --osm-base --terminate"
133 standard_output "append:#{logdir}/osm_base.log"
137 service "overpass-dispatcher" do
141 systemd_service "overpass-area-dispatcher" do
142 description "Overpass Area Dispatcher"
143 after ["overpass-dispatcher"]
144 working_directory basedir
145 exec_start "#{basedir}/bin/dispatcher --areas #{meta_map_short[node[:overpass][:meta_mode]]} --db-dir=#{basedir}/db"
146 exec_stop "#{basedir}/bin/dispatcher --areas --terminate"
147 standard_output "append:#{logdir}/areas.log"
151 service "overpass-area-dispatcher" do
155 systemd_service "overpass-update" do
156 description "Overpass Update Application"
157 after ["overpass-dispatcher"]
158 working_directory basedir
159 exec_start "#{basedir}/bin/overpass-update-db"
160 standard_output "append:#{logdir}/update.log"
164 if node[:overpass][:meta_mode] == "attic"
165 systemd_service "overpass-area-processor" do
166 description "Overpass Area Processor"
167 after ["overpass-area-dispatcher"]
168 working_directory basedir
169 exec_start "#{basedir}/bin/overpass-update-areas"
170 standard_output "append:#{logdir}/area-processor.log"
175 systemd_service "overpass-area-processor" do
176 description "Overpass Area Processor"
177 after ["overpass-area-dispatcher"]
178 working_directory basedir
179 exec_start "#{basedir}/bin/osm3s_query --progress --rules"
180 standard_input "file:#{srcdir}/rules/areas.osm3s"
181 standard_output "append:#{logdir}/area-processor.log"
187 systemd_timer "overpass-area-processor" do
188 description "Update areas in Overpass"
189 on_calendar "*-*-* *:*:00"
192 service "overpass-area-processor" do