]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/nominatim/recipes/default.rb
Replace cron.d templates with cron_d resources
[chef.git] / cookbooks / nominatim / recipes / default.rb
index 46a03fc9148ade9af1003d54adb77b82144389de..78bede8ce5eb220fd79ad946686df07482ad3669 100644 (file)
@@ -19,6 +19,7 @@
 
 include_recipe "accounts"
 include_recipe "munin"
+include_recipe "php::fpm"
 
 basedir = data_bag_item("accounts", "nominatim")["home"]
 email_errors = data_bag_item("accounts", "lonvia")["email"]
@@ -167,8 +168,6 @@ package %w[
   python3-pyosmium
   pyosmium
   python3-psycopg2
-  php
-  php-fpm
   php-pgsql
   php-intl
 ]
@@ -263,15 +262,61 @@ remote_file "#{source_directory}/data/country_osm_grid.sql.gz" do
   mode 0o644
 end
 
-template "/etc/cron.d/nominatim" do
-  action node[:nominatim][:state] == "off" ? :delete : :create
-  source "nominatim.cron.erb"
-  owner "root"
-  group "root"
-  mode "0644"
-  variables :bin_directory => "#{source_directory}/utils",
-            :mailto => email_errors,
-            :update_maintenance_trigger => "#{basedir}/status/update_maintenance"
+file "/etc/cron.d/nominatim" do
+  action :delete
+end
+
+if node[:nominatim][:state] == "off"
+  cron_d "nominatim-backup" do
+    action :delete
+  end
+
+  cron_d "nominatim-vacuum-db" do
+    action :delete
+  end
+
+  cron_d "nominatim-clean-db" do
+    action :delete
+  end
+
+  cron_d "nominatim-update-maintenance-trigger" do
+    action :delete
+  end
+else
+  cron_d "nominatim-backup" do
+    action node[:nominatim][:enable_backup] ? :create : :delete
+    minute "0"
+    hour "3"
+    day "1"
+    user "nominatim"
+    command "/usr/local/bin/backup-nominatim"
+    mailto email_errors
+  end
+
+  cron_d "nominatim-vacuum-db" do
+    minute "20"
+    hour "0"
+    user "postgres"
+    command "/usr/local/bin/vacuum-db-nominatim"
+    mailto email_errors
+  end
+
+  cron_d "nominatim-clean-db" do
+    action node[:nominatim][:state] == "master" ? :create : :delete
+    minute "5"
+    hour "*/4"
+    user "postgres"
+    command "/usr/local/bin/clean-db-nominatim"
+    mailto email_errors
+  end
+
+  cron_d "nominatim-update-maintenance-trigger" do
+    minute "18"
+    hour "1"
+    user "nominatim"
+    command "touch #{basedir}/status/update_maintenance"
+    mailto email_errors
+  end
 end
 
 template "#{source_directory}/utils/nominatim-update" do
@@ -322,19 +367,10 @@ end
   end
 end
 
-service "php7.2-fpm" do
-  action [:enable, :start]
-  supports :status => true, :restart => true, :reload => true
-end
-
 node[:nominatim][:fpm_pools].each do |name, data|
-  template "/etc/php/7.2/fpm/pool.d/#{name}.conf" do
-    source "fpm.conf.erb"
-    owner "root"
-    group "root"
-    mode 0o644
+  php_fpm name do
+    template "fpm.conf.erb"
     variables data.merge(:name => name)
-    notifies :reload, "service[php7.2-fpm]"
   end
 end