diff options
author | jkeiser <jkeiser@opscode.com> | 2012-12-24 08:48:51 -0800 |
---|---|---|
committer | jkeiser <jkeiser@opscode.com> | 2012-12-24 08:48:51 -0800 |
commit | 0a81ab3b3f0352a922414b07093440cf6ba1b433 (patch) | |
tree | ec127518d4f4e99d9dbf800c42c8f7925cc1e9b1 | |
parent | ee7f26b036e0fdfd545f1eeb73fdb0b197e6bf81 (diff) | |
download | chef-zero-0a81ab3b3f0352a922414b07093440cf6ba1b433.tar.gz |
Make stop more reliable (don't kill the thread unless necessary)
-rw-r--r-- | lib/chef_zero/server.rb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/chef_zero/server.rb b/lib/chef_zero/server.rb index ff661ca..42774e8 100644 --- a/lib/chef_zero/server.rb +++ b/lib/chef_zero/server.rb @@ -117,14 +117,13 @@ module ChefZero end def stop(timeout = 5) - Timeout::timeout(timeout) do + begin server.stop - until !server.running? || !server_error - sleep(0.01) - end - end - if @thread - @thread.kill + @thread.join(timeout) + @thread = nil + rescue + Chef::Log.error("Server did not stop within #{timeout}s. Killing.") + @thread.kill if @thread @thread = nil end end |