summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsersut <serdar@opscode.com>2013-02-21 11:49:31 -0800
committersersut <serdar@opscode.com>2013-02-21 11:49:31 -0800
commitb81ee58be871800b022e84bd2d331c57645b6b80 (patch)
treedf9f844921544f9ef6c92a24811f16e6d38f1114
parentc20b0324b0b2e162ce95584bef685d112bf7201d (diff)
downloadchef-b81ee58be871800b022e84bd2d331c57645b6b80.tar.gz
Enable chef-client windows_service to stop in a timely manner when splay is configured with a high number.
-rw-r--r--lib/chef/application/windows_service.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb
index d3493d8a47..42a9ee9783 100644
--- a/lib/chef/application/windows_service.rb
+++ b/lib/chef/application/windows_service.rb
@@ -65,7 +65,9 @@ class Chef
end
def service_main(*startup_parameters)
- timeout = 0
+ # Chef::Config is initialized during service_init
+ # Set the initial timeout to splay sleep time
+ timeout = rand Chef::Config[:splay]
while running? do
# Grab the service_action_mutex to make a chef-client run
@@ -83,10 +85,7 @@ class Chef
timeout = Chef::Config[:interval]
# Honor splay sleep config
-
- splay = rand Chef::Config[:splay]
- Chef::Log.debug("Splay sleep #{splay} seconds")
- sleep splay
+ timeout += rand Chef::Config[:splay]
# run chef-client only if service is in RUNNING state
next if state != RUNNING