diff options
author | John Keiser <jkeiser@opscode.com> | 2013-11-01 17:00:19 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-11-01 17:00:19 -0700 |
commit | ecb30496173cefb33531b09776bd348ab3f5024a (patch) | |
tree | 6e435f9f968373cce61eb524d75268208fc673ee /lib/chef_zero/server.rb | |
parent | 7c387746375a9ae1de43aab2183e81ef0fc3acdb (diff) | |
download | chef-zero-ecb30496173cefb33531b09776bd348ab3f5024a.tar.gz |
Fix Logger line to be cross-platform, use webrick.shutdown method to stop server
Diffstat (limited to 'lib/chef_zero/server.rb')
-rw-r--r-- | lib/chef_zero/server.rb | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/lib/chef_zero/server.rb b/lib/chef_zero/server.rb index 17fcea2..6d3fcf6 100644 --- a/lib/chef_zero/server.rb +++ b/lib/chef_zero/server.rb @@ -19,6 +19,7 @@ require 'openssl' require 'rubygems' require 'timeout' +require 'stringio' require 'chef_zero' require 'chef_zero/cookbook_data' @@ -118,17 +119,20 @@ module ChefZero :BindAddress => @options[:host], :Port => @options[:port], :AccessLog => [], - :Logger => WEBrick::Log::new("/dev/null", 7) + :Logger => WEBrick::Log::new(StringIO.new, 7) ) do |server| @server = server end end rescue Object, Interrupt - puts "\n>> Stopping Chef Zero ..." - case @server_type - when :puma - server.stop(true) if running? - else + if running? + puts "\n>> Stopping Chef Zero ..." + case @server_type + when :puma + server.stop(true) + when :webrick + server.shutdown + end end ensure case @server_type @@ -172,16 +176,19 @@ module ChefZero case @server_type when :puma server.stop(true) - if @thread - @thread.join(wait) - end when :webrick - @thread.kill if @thread + server.shutdown + @server end - rescue if @thread - ChefZero::Log.error "Server did not stop within #{wait} seconds. Killing..." - @thread.kill + begin + @thread.join(wait) if @thread + rescue + if @thread + ChefZero::Log.error "Server did not stop within #{wait} seconds. Killing..." + @thread.kill + end + end end ensure @thread = nil |