From c1d216479f8ffd373f29c77e1e3c23c2bac168fe Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 31 Jan 2016 19:09:25 +0000 Subject: [PATCH] Restart nginx after an imagery_site is updated --- cookbooks/imagery/.foodcritic | 1 + cookbooks/imagery/resources/layer.rb | 2 -- cookbooks/imagery/resources/site.rb | 5 +++++ cookbooks/nginx/resources/site.rb | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 cookbooks/imagery/.foodcritic diff --git a/cookbooks/imagery/.foodcritic b/cookbooks/imagery/.foodcritic new file mode 100644 index 000000000..913f038a4 --- /dev/null +++ b/cookbooks/imagery/.foodcritic @@ -0,0 +1 @@ +~FC005 diff --git a/cookbooks/imagery/resources/layer.rb b/cookbooks/imagery/resources/layer.rb index 63e0ba91d..7adcba920 100644 --- a/cookbooks/imagery/resources/layer.rb +++ b/cookbooks/imagery/resources/layer.rb @@ -76,7 +76,6 @@ action :create do group "root" mode 0644 variables new_resource.to_hash - # FIXME notifies :reload, "service[nginx]", :delayed end end @@ -97,6 +96,5 @@ action :delete do file "/srv/imagery/nginx/#{site}/layer-#{name}.conf" do action :delete - # FIXME notifies :reload, "service[nginx]", :delayed end end diff --git a/cookbooks/imagery/resources/site.rb b/cookbooks/imagery/resources/site.rb index dfda20da1..3edeb9038 100644 --- a/cookbooks/imagery/resources/site.rb +++ b/cookbooks/imagery/resources/site.rb @@ -31,6 +31,11 @@ action :create do nginx_site name do template "nginx_imagery.conf.erb" directory "/srv/imagery/#{name}" + restart_nginx false variables new_resource.to_hash end end + +def after_created + notifies :restart, "service[nginx]" +end diff --git a/cookbooks/nginx/resources/site.rb b/cookbooks/nginx/resources/site.rb index bdea43487..e48e7b80d 100644 --- a/cookbooks/nginx/resources/site.rb +++ b/cookbooks/nginx/resources/site.rb @@ -25,7 +25,8 @@ attribute :directory, :kind_of => String attribute :cookbook, :kind_of => String attribute :template, :kind_of => String, :required => true attribute :variables, :kind_of => Hash, :default => {} +attribute :restart_nginx, :kind_of => [TrueClass, FalseClass], :default => true def after_created - notifies :restart, "service[nginx]" + notifies :restart, "service[nginx]" if restart_nginx end -- 2.39.5