From 128b54ff815f5de7498e6ea22cae37cec36e3eeb Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sat, 15 Sep 2018 14:42:21 +0100 Subject: [PATCH] Switch taginfo to use planet::current --- cookbooks/taginfo/recipes/default.rb | 45 +++++++------------ .../templates/default/configuration.txt.erb | 4 -- cookbooks/taginfo/templates/default/cron.erb | 9 ---- .../taginfo/templates/default/logrotate.erb | 14 ------ .../templates/default/taginfo-update.erb | 11 +++++ .../templates/default/update-planet.erb | 39 ---------------- .../templates/default/update-taginfo.erb | 24 ---------- .../taginfo/templates/default/update.erb | 22 ++++++++- roles/taginfo.rb | 9 ++++ 9 files changed, 55 insertions(+), 122 deletions(-) delete mode 100644 cookbooks/taginfo/templates/default/configuration.txt.erb delete mode 100644 cookbooks/taginfo/templates/default/cron.erb delete mode 100644 cookbooks/taginfo/templates/default/logrotate.erb create mode 100644 cookbooks/taginfo/templates/default/taginfo-update.erb delete mode 100644 cookbooks/taginfo/templates/default/update-planet.erb delete mode 100644 cookbooks/taginfo/templates/default/update-taginfo.erb diff --git a/cookbooks/taginfo/recipes/default.rb b/cookbooks/taginfo/recipes/default.rb index b614c9580..43cb17b29 100644 --- a/cookbooks/taginfo/recipes/default.rb +++ b/cookbooks/taginfo/recipes/default.rb @@ -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 index 398fce503..000000000 --- a/cookbooks/taginfo/templates/default/configuration.txt.erb +++ /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 index 625dfbe39..000000000 --- a/cookbooks/taginfo/templates/default/cron.erb +++ /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 index bf6f4a842..000000000 --- a/cookbooks/taginfo/templates/default/logrotate.erb +++ /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 index 000000000..0dd05b847 --- /dev/null +++ b/cookbooks/taginfo/templates/default/taginfo-update.erb @@ -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 index 50e058632..000000000 --- a/cookbooks/taginfo/templates/default/update-planet.erb +++ /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 index 805129e05..000000000 --- a/cookbooks/taginfo/templates/default/update-taginfo.erb +++ /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 diff --git a/cookbooks/taginfo/templates/default/update.erb b/cookbooks/taginfo/templates/default/update.erb index be76ae997..99b322f57 100644 --- a/cookbooks/taginfo/templates/default/update.erb +++ b/cookbooks/taginfo/templates/default/update.erb @@ -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 diff --git a/roles/taginfo.rb b/roles/taginfo.rb index fb0bea3b5..b7233afca 100644 --- a/roles/taginfo.rb +++ b/roles/taginfo.rb @@ -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]" ) -- 2.43.2