diff options
author | Claire McQuin <claire@getchef.com> | 2014-06-12 11:42:34 -0700 |
---|---|---|
committer | Claire McQuin <claire@getchef.com> | 2014-06-18 15:26:20 -0700 |
commit | 27bfcc144afb48b40ab04aaded05744cab456bbe (patch) | |
tree | d577986fc41ee333eee213c7b418e0a004363074 | |
parent | 598b3b28769f5019546fd8eaa33524d36e78ceb1 (diff) | |
download | chef-27bfcc144afb48b40ab04aaded05744cab456bbe.tar.gz |
add worker threadCHEF-4600
-rw-r--r-- | lib/chef/provider/service/windows.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/chef/provider/service/windows.rb b/lib/chef/provider/service/windows.rb index 0e26325d30..beda766b17 100644 --- a/lib/chef/provider/service/windows.rb +++ b/lib/chef/provider/service/windows.rb @@ -72,7 +72,7 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service Chef::Log.debug "#{@new_resource} starting service using the given start_command" shell_out!(@new_resource.start_command) else - command_timeout do + spawn_command_thread do Win32::Service.start(@new_resource.service_name) wait_for_state(RUNNING) end @@ -94,7 +94,7 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service Chef::Log.debug "#{@new_resource} stopping service using the given stop_command" shell_out!(@new_resource.stop_command) else - command_timeout do + spawn_command_thread do Win32::Service.stop(@new_resource.service_name) wait_for_state(STOPPED) end @@ -177,13 +177,15 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service sleep 1 until current_state == desired_state end - def command_timeout - timeout = @new_resource.timeout if @new_resource.timeout - timeout ||= TIMEOUT - Chef::Log.debug "service command timeout [#{timeout}]" - - Timeout.timeout(timeout) do + def spawn_command_thread + worker = Thread.new do yield end + + resource_timeout = @new_resource.timeout if @new_resource.timeout + resource_timeout ||= TIMEOUT + Timeout.timeout(resource_timeout) do + worker.join + end end end |