Switch taginfo to use planet::current
authorTom Hughes <tom@compton.nu>
Sat, 15 Sep 2018 13:42:21 +0000 (14:42 +0100)
committerTom Hughes <tom@compton.nu>
Sat, 15 Sep 2018 13:50:01 +0000 (14:50 +0100)
cookbooks/taginfo/recipes/default.rb
cookbooks/taginfo/templates/default/configuration.txt.erb [deleted file]
cookbooks/taginfo/templates/default/cron.erb [deleted file]
cookbooks/taginfo/templates/default/logrotate.erb [deleted file]
cookbooks/taginfo/templates/default/taginfo-update.erb [new file with mode: 0644]
cookbooks/taginfo/templates/default/update-planet.erb [deleted file]
cookbooks/taginfo/templates/default/update-taginfo.erb [deleted file]
cookbooks/taginfo/templates/default/update.erb
roles/taginfo.rb

index b614c95803e585c42210c06ea51378770aea4683..43cb17b294c40010e9eae86035fc96944424d903 100644 (file)
@@ -62,11 +62,8 @@ apache_module "cache"
 apache_module "cache_disk"
 apache_module "headers"
 
-template "/etc/cron.d/taginfo" do
-  source "cron.erb"
-  owner "root"
-  group "root"
-  mode 0o644
+file "/etc/cron.d/taginfo" do
+  action :delete
 end
 
 directory "/var/log/taginfo" do
@@ -75,10 +72,6 @@ directory "/var/log/taginfo" do
   mode 0o755
 end
 
-file "/etc/logrotate.d/taginfo" do
-  action :delete
-end
-
 template "/etc/sudoers.d/taginfo" do
   source "sudoers.erb"
   owner "root"
@@ -129,7 +122,7 @@ node[:taginfo][:sites].each do |site|
     settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
     settings["sources"]["download"] = ""
     settings["sources"]["create"] = "db languages projects wiki"
-    settings["sources"]["db"]["planetfile"] = "#{directory}/planet/planet.pbf"
+    settings["sources"]["db"]["planetfile"] = "/var/lib/planet/planet.pbf"
     settings["sources"]["db"]["bindir"] = "#{directory}/taginfo/tagstats"
     settings["tagstats"]["geodistribution"] = "DenseMmapArray"
 
@@ -175,28 +168,12 @@ node[:taginfo][:sites].each do |site|
     end
   end
 
-  remote_file "#{directory}/planet/planet.pbf" do
-    action :create_if_missing
-    source "https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf"
-    owner "taginfo"
-    group "taginfo"
-    mode 0o644
-  end
-
-  template "#{directory}/bin/update-planet" do
-    source "update-planet.erb"
-    owner "taginfo"
-    group "taginfo"
-    mode 0o755
-    variables :directory => directory
+  file "#{directory}/bin/update-planet" do
+    action :delete
   end
 
-  template "#{directory}/bin/update-taginfo" do
-    source "update-taginfo.erb"
-    owner "taginfo"
-    group "taginfo"
-    mode 0o755
-    variables :directory => directory
+  file "#{directory}/bin/update-taginfo" do
+    action :delete
   end
 
   template "#{directory}/bin/update" do
@@ -220,3 +197,11 @@ node[:taginfo][:sites].each do |site|
     variables :aliases => site_aliases
   end
 end
+
+template "/usr/local/bin/taginfo-update" do
+  source "taginfo-update.erb"
+  owner "root"
+  group "root"
+  mode 0o755
+  variables :sites => node[:taginfo][:sites]
+end
diff --git a/cookbooks/taginfo/templates/default/configuration.txt.erb b/cookbooks/taginfo/templates/default/configuration.txt.erb
deleted file mode 100644 (file)
index 398fce5..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-baseUrl=https://planet.openstreetmap.org/replication/hour
-maxInterval=0
diff --git a/cookbooks/taginfo/templates/default/cron.erb b/cookbooks/taginfo/templates/default/cron.erb
deleted file mode 100644 (file)
index 625dfbe..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-<% node[:taginfo][:sites].each do |site| -%>
-<% if site[:directory] -%>
-17 1 * * * taginfo <%= site[:directory] %>/bin/update
-<% else -%>
-17 1 * * * taginfo /srv/<%= site[:name] %>/bin/update
-<% end -%>
-<% end -%>
diff --git a/cookbooks/taginfo/templates/default/logrotate.erb b/cookbooks/taginfo/templates/default/logrotate.erb
deleted file mode 100644 (file)
index bf6f4a8..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-<% node[:taginfo][:sites].each do |site| -%>
-
-/var/log/taginfo/<%= site[:name] %>/*.log {
-  daily
-  missingok
-  rotate 0
-  dateext
-  dateformat %Y-%m-%d
-  maxage 28
-  compress
-  delaycompress
-}
-<% end -%>
diff --git a/cookbooks/taginfo/templates/default/taginfo-update.erb b/cookbooks/taginfo/templates/default/taginfo-update.erb
new file mode 100644 (file)
index 0000000..0dd05b8
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+<% @sites.each do |site| -%>
+<% if site[:directory] -%>
+<%= site[:directory] %>/bin/update
+<% else -%>
+/srv/<%= site[:name] %>/bin/update
+<% end -%>
+<% end -%>
diff --git a/cookbooks/taginfo/templates/default/update-planet.erb b/cookbooks/taginfo/templates/default/update-planet.erb
deleted file mode 100644 (file)
index 50e0586..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/sh
-
-# DO NOT EDIT - This file is being maintained by Chef
-
-# setup
-
-PLANETDIR="<%= @directory %>/planet"
-LOGDIR="${PLANETDIR}/log"
-PLANETPREV="${PLANETDIR}/planet-previous.pbf"
-PLANETCURR="${PLANETDIR}/planet.pbf"
-PLANETNEW="${PLANETDIR}/planet-new.pbf"
-PLANETTMP="${PLANETDIR}/planet-tmp.pbf"
-
-# start logging
-
-exec > "${LOGDIR}/$(date +%Y%m%d-%H%M).log" 2>&1
-
-pyosmium-up-to-date -v -o $PLANETNEW $PLANETCURR
-retval=$?
-
-while [ $retval -eq 1 ]; do
-    mv "$PLANETNEW" "$PLANETTMP"
-    pyosmium-up-to-date -v -o $PLANETNEW $PLANETTMP
-    retval=$?
-    rm "$PLANETTMP"
-done
-
-if [ $retval -ne 0 ]; then
-  exit $retval
-fi
-
-# cleanup
-
-mv "$PLANETCURR" "$PLANETPREV"
-mv "$PLANETNEW" "$PLANETCURR"
-
-# expire old logs
-
-find "${LOGDIR}" -mtime +28 -delete
diff --git a/cookbooks/taginfo/templates/default/update-taginfo.erb b/cookbooks/taginfo/templates/default/update-taginfo.erb
deleted file mode 100644 (file)
index 805129e..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-# DO NOT EDIT - This file is being maintained by Chef
-
-set -e
-
-ROOT="<%= @directory %>"
-
-cd $ROOT/taginfo/sources
-
-if [ -f "$ROOT/data/taginfo-history.db" ]
-then
-    cp $ROOT/data/taginfo-history.db $ROOT/sources
-fi
-
-$ROOT/taginfo/sources/update_all.sh $ROOT/sources
-
-mv $ROOT/data/taginfo-* $ROOT/data/old
-mv $ROOT/sources/taginfo-*.db $ROOT/sources/*/taginfo-*.db $ROOT/data
-mv $ROOT/sources/download/* $ROOT/download
-
-sudo PASSENGER_INSTANCE_REGISTRY_DIR=<%= node[:passenger][:instance_registry_dir] %> /usr/bin/passenger-config restart-app $ROOT/taginfo/web > /dev/null
-
-find $ROOT/sources/log -mtime +28 -delete
index be76ae99754fedd911c6f12ee5daa70e64d8da4e..99b322f57468357c1a844d875c76f37d49f0c6dc 100644 (file)
@@ -2,7 +2,25 @@
 
 # DO NOT EDIT - This file is being maintained by Chef
 
-<%= @directory %>/bin/update-planet
-<%= @directory %>/bin/update-taginfo
+set -e
+
+ROOT="<%= @directory %>"
+
+cd $ROOT/taginfo/sources
+
+if [ -f "$ROOT/data/taginfo-history.db" ]
+then
+    cp $ROOT/data/taginfo-history.db $ROOT/sources
+fi
+
+$ROOT/taginfo/sources/update_all.sh $ROOT/sources
+
+mv $ROOT/data/taginfo-* $ROOT/data/old
+mv $ROOT/sources/taginfo-*.db $ROOT/sources/*/taginfo-*.db $ROOT/data
+mv $ROOT/sources/download/* $ROOT/download
+
+sudo PASSENGER_INSTANCE_REGISTRY_DIR=<%= node[:passenger][:instance_registry_dir] %> /usr/bin/passenger-config restart-app $ROOT/taginfo/web > /dev/null
+
+find $ROOT/sources/log -mtime +28 -delete
 
 find "/var/log/taginfo/<%= @name %>" -mtime +28 -delete
index fb0bea3b585aaefde57ab5a6ca4bb9554c7d3b17..b7233afca73dcbcb5296423d1284bed53354e815 100644 (file)
@@ -27,6 +27,14 @@ default_attributes(
   :passenger => {
     :max_pool_size => 50
   },
+  :planet => {
+    :current => {
+      :taginfo => {
+        :command => "/usr/local/bin/taginfo-update",
+        :user => "taginfo"
+      }
+    }
+  },
   :taginfo => {
     :sites => [
       {
@@ -42,5 +50,6 @@ default_attributes(
 )
 
 run_list(
+  "recipe[planet::current]",
   "recipe[taginfo]"
 )