diff options
author | AbhishekKr <abhikumar163@gmail.com> | 2016-09-10 09:00:35 +0530 |
---|---|---|
committer | AbhishekKr <abhikumar163@gmail.com> | 2016-09-10 09:00:35 +0530 |
commit | ff19b559b6bd139e6701cfcf4f7b065fb01f9fa7 (patch) | |
tree | 63d9e52e490c38d7be836c78ec9ca6393983471b /lib/chef/provider | |
parent | 5c01c0f74941d4f788e254ae4d040c0e4a2a477d (diff) | |
download | chef-ff19b559b6bd139e6701cfcf4f7b065fb01f9fa7.tar.gz |
service - upstart restart - service status managed via attr_accessor
Diffstat (limited to 'lib/chef/provider')
-rw-r--r-- | lib/chef/provider/service/upstart.rb | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb index 941c4209dd..03de1373ca 100644 --- a/lib/chef/provider/service/upstart.rb +++ b/lib/chef/provider/service/upstart.rb @@ -26,6 +26,8 @@ class Chef class Service class Upstart < Chef::Provider::Service::Simple + attr_accessor :upstart_service_running + provides :service, platform_family: "debian", override: true do |node| Chef::Platform::ServiceHelpers.service_resource_providers.include?(:upstart) end @@ -110,23 +112,23 @@ class Chef begin if shell_out!(@new_resource.status_command).exitstatus == 0 - @current_resource.running true + @upstart_service_running = true end rescue @command_success = false - @current_resource.running false + @upstart_service_running = false nil end else begin if upstart_goal_state == "start" - @current_resource.running true + @upstart_service_running = true else - @current_resource.running false + @upstart_service_running = false end rescue Chef::Exceptions::Exec @command_success = false - @current_resource.running false + @upstart_service_running = false nil end end @@ -153,13 +155,14 @@ class Chef @current_resource.enabled false end + @current_resource.running @upstart_service_running @current_resource end def start_service # Calling start on a service that is already started will return 1 # Our 'goal' when we call start is to ensure the service is started - if @current_resource.running + if @upstart_service_running Chef::Log.debug("#{@new_resource} already running, not starting") else if @new_resource.start_command @@ -168,12 +171,14 @@ class Chef shell_out_with_systems_locale!("/sbin/start #{@job}") end end + + @upstart_service_running = true end def stop_service # Calling stop on a service that is already stopped will return 1 # Our 'goal' when we call stop is to ensure the service is stopped - unless @current_resource.running + unless @upstart_service_running Chef::Log.debug("#{@new_resource} not running, not stopping") else if @new_resource.stop_command @@ -182,6 +187,8 @@ class Chef shell_out_with_systems_locale!("/sbin/stop #{@job}") end end + + @upstart_service_running = false end def restart_service @@ -192,7 +199,7 @@ class Chef # But for safe working of latest upstart job config being loaded, 'restart' can't be used as per link # http://upstart.ubuntu.com/cookbook/#restart (it doesn't uses latest jon config from disk but retains old) else - if @current_resource.running + if @upstart_service_running stop_service sleep 1 start_service @@ -200,6 +207,8 @@ class Chef start_service end end + + @upstart_service_running = true end def reload_service @@ -209,6 +218,8 @@ class Chef # upstart >= 0.6.3-4 supports reload (HUP) shell_out_with_systems_locale!("/sbin/reload #{@job}") end + + @upstart_service_running = true end # https://bugs.launchpad.net/upstart/+bug/94065 |