diff options
author | Noah Kantrowitz <noah@coderanger.net> | 2015-02-19 13:16:02 -0800 |
---|---|---|
committer | Bryan McLellan <btm@chef.io> | 2015-05-01 18:46:06 -0400 |
commit | ddb82fa280f5259790c7b6c7df08666a3f07b299 (patch) | |
tree | 6819b9fb26a621338f9943f086e69ba463ca9ee7 /lib/chef/platform/service_helpers.rb | |
parent | 49c9146d86a019dd2bdc80c59b62e2c10bcd5412 (diff) | |
download | chef-ddb82fa280f5259790c7b6c7df08666a3f07b299.tar.gz |
Cache service_resource_providers for the duration of the run.
Diffstat (limited to 'lib/chef/platform/service_helpers.rb')
-rw-r--r-- | lib/chef/platform/service_helpers.rb | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/chef/platform/service_helpers.rb b/lib/chef/platform/service_helpers.rb index dc0a808c06..d50812e687 100644 --- a/lib/chef/platform/service_helpers.rb +++ b/lib/chef/platform/service_helpers.rb @@ -42,34 +42,34 @@ class Chef # different services is NOT a design concern of this module. # def service_resource_providers - service_resource_providers = [] + @service_resource_providers ||= [].tap do |service_resource_providers| - if ::File.exist?("/usr/sbin/update-rc.d") - service_resource_providers << :debian - end + if ::File.exist?("/usr/sbin/update-rc.d") + service_resource_providers << :debian + end - if ::File.exist?("/usr/sbin/invoke-rc.d") - service_resource_providers << :invokercd - end + if ::File.exist?("/usr/sbin/invoke-rc.d") + service_resource_providers << :invokercd + end - if ::File.exist?("/sbin/insserv") - service_resource_providers << :insserv - end + if ::File.exist?("/sbin/insserv") + service_resource_providers << :insserv + end - # debian >= 6.0 has /etc/init but does not have upstart - if ::File.exist?("/etc/init") && ::File.exist?("/sbin/start") - service_resource_providers << :upstart - end + # debian >= 6.0 has /etc/init but does not have upstart + if ::File.exist?("/etc/init") && ::File.exist?("/sbin/start") + service_resource_providers << :upstart + end - if ::File.exist?("/sbin/chkconfig") - service_resource_providers << :redhat - end + if ::File.exist?("/sbin/chkconfig") + service_resource_providers << :redhat + end - if systemd_sanity_check? - service_resource_providers << :systemd - end + if systemd_sanity_check? + service_resource_providers << :systemd + end - service_resource_providers + end end def config_for_service(service_name) |