X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/1c848471a16f9d1ee1fc8a327af110447ea1ef4c..acb5ea419113188317bc7bede334b90e12efd5ce:/cookbooks/db/recipes/master.rb diff --git a/cookbooks/db/recipes/master.rb b/cookbooks/db/recipes/master.rb index 70ae0e673..905d7a221 100644 --- a/cookbooks/db/recipes/master.rb +++ b/cookbooks/db/recipes/master.rb @@ -1,14 +1,14 @@ # -# Cookbook Name:: db +# Cookbook:: db # Recipe:: master # -# Copyright 2011, OpenStreetMap Foundation +# Copyright:: 2011, OpenStreetMap Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -49,6 +49,7 @@ end postgresql_user "planetdiff" do cluster node[:db][:cluster] password passwords["planetdiff"] + replication true end postgresql_user "backup" do @@ -80,12 +81,28 @@ end postgresql_extension "btree_gist" do cluster node[:db][:cluster] database "openstreetmap" - only_if { node[:postgresql][:clusters][node[:db][:cluster]] and node[:postgresql][:clusters][node[:db][:cluster]][:version] >= 9.0 } + only_if { node[:postgresql][:clusters][node[:db][:cluster]] && node[:postgresql][:clusters][node[:db][:cluster]][:version] >= 9.0 } end -template "/etc/cron.daily/rails-db" do - source "cron.erb" +cookbook_file "/usr/local/share/monthly-reindex.sql" do owner "root" group "root" - mode 0755 + mode "644" +end + +systemd_service "monthly-reindex" do + description "Monthly database reindex" + exec_start "/usr/bin/psql -f /usr/local/share/monthly-reindex.sql openstreetmap" + user "postgres" + sandbox true + restrict_address_families "AF_UNIX" +end + +systemd_timer "monthly-reindex" do + description "Monthly database reindex" + on_calendar "Sun *-*-1..7 02:00" +end + +service "monthly-reindex.timer" do + action [:enable, :start] end