From a2cc61fc04a3f25bd5bb5d64ffa5fceca252c4a3 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 16 Feb 2020 17:09:02 +0000 Subject: [PATCH] Move cron customisation for tile caches to the tools cookbook --- cookbooks/tilecache/recipes/default.rb | 10 ---------- cookbooks/tools/attributes/default.rb | 1 + cookbooks/tools/recipes/default.rb | 12 ++++++++++++ roles/tilecache.rb | 9 +++++++++ 4 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 cookbooks/tools/attributes/default.rb diff --git a/cookbooks/tilecache/recipes/default.rb b/cookbooks/tilecache/recipes/default.rb index 1cf0e7b2e..f1bab2e57 100644 --- a/cookbooks/tilecache/recipes/default.rb +++ b/cookbooks/tilecache/recipes/default.rb @@ -110,16 +110,6 @@ template "/etc/logrotate.d/squid" do mode 0o644 end -# Configure cron with lower cpu and IO priority -systemd_service "cron-load" do - service "cron" - dropin "load" - nice 19 - io_scheduling_class "best-effort" - io_scheduling_priority 7 - notifies :restart, "service[cron]" -end - nginx_site "default" do action [:delete] end diff --git a/cookbooks/tools/attributes/default.rb b/cookbooks/tools/attributes/default.rb new file mode 100644 index 000000000..b77bd1b60 --- /dev/null +++ b/cookbooks/tools/attributes/default.rb @@ -0,0 +1 @@ +default[:tools][:cron] = {} diff --git a/cookbooks/tools/recipes/default.rb b/cookbooks/tools/recipes/default.rb index 8b6fbfc62..b5e12de2c 100644 --- a/cookbooks/tools/recipes/default.rb +++ b/cookbooks/tools/recipes/default.rb @@ -58,6 +58,18 @@ systemd_service "cron-timezone" do only_if { node[:timezone] } end +# Configure cron with lower cpu and IO priority +if node[:tools][:cron][:load] + systemd_service "cron-load" do + service "cron" + dropin "load" + nice node[:tools][:cron][:load][:nice] + io_scheduling_class node[:tools][:cron][:load][:io_scheduling_class] + io_scheduling_priority node[:tools][:cron][:load][:io_scheduling_priority] + notifies :restart, "service[cron]" + end +end + # Make sure cron is running service "cron" do action [:enable, :start] diff --git a/roles/tilecache.rb b/roles/tilecache.rb index d60617107..dc6fadf7b 100644 --- a/roles/tilecache.rb +++ b/roles/tilecache.rb @@ -74,6 +74,15 @@ default_attributes( "kernel.sched_wakeup_granularity_ns" => "15000000" } } + }, + :tools => { + :cron => { + :load => { + :nice => 19, + :io_scheduling_class => "best-effort", + :io_scheduling_priority => 7 + } + } } ) -- 2.45.1