Created
November 8, 2012 02:43
-
-
Save elebertus/4036273 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
action :start_stop do | |
begin | |
@new_resource.start_service(node[:service_status][:state]) | |
rescue | |
Chef::Log.warn("----------") | |
Chef::Log.warn("Application default state is missing. Defaulting to start the service. If this cluster or service should not automatically start defined node[:service_status][:state]") | |
Chef::Log.warn("----------") | |
@new_resource.start_service("start") | |
@new_resource.env_state("start") | |
end | |
begin | |
@new_resource.start_service("#{node[:some_application][:"#{@new_resource.name}"][:state]}") | |
rescue | |
Chef::Log.warn("----------") | |
Chef::Log.warn("Node override state is missing. Using environment service state settings. Define node[:some_application][:#{@new_resource.name}][:state] if you need to control a single node's state") | |
Chef::Log.warn("----------") | |
@new_resource.node_state(@new_resource.env_state) | |
end | |
if @new_resource.start_service == "start" | |
service "#{@new_resource.name}" do | |
action :start | |
end | |
elsif @new_resource.start_service == "stop" | |
service "#{@new_resource.name}" do | |
action :stop | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment