Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use rack's SIGINT trap, join, shutdown in handler, drop :embedded opt

  • Loading branch information...
commit e3b6d191dffa3cf4dbfa67cbb5e2ff45295ca020 1 parent a545442
@dekellum authored
View
12 lib/mizuno/http_server.rb
@@ -53,15 +53,13 @@ def self.run(app, options = {})
# Add the context to the server and start.
@server.set_handler(context)
- @server.start
- # Stop the server when we get The Signal.
- trap("SIGINT") { @server.stop and exit }
+ @server.stop_at_shutdown = true
+ @server.start
+ end
- # Join with the server thread, so that currently open file
- # descriptors don't get closed by accident.
- # http://www.ruby-forum.com/topic/209252
- @server.join unless options[:embedded]
+ def self.join
+ @server.join if @server
end
#
View
13 lib/rack/handler/mizuno.rb
@@ -2,10 +2,19 @@
module Rack
module Handler
- module Mizuno
+ # Rack expects Rack::Handler::Mizuno via require 'rack/handler/mizuno'
+ class Mizuno
+ Server = ::Mizuno::HttpServer
+ # Called by rack to run
def self.run( app, opts = {} )
- ::Mizuno::HttpServer.run( app, opts )
+ Server.run( app, opts )
+ Server.join
+ end
+
+ # Called by rack
+ def self.shutdown
+ Server.stop
end
end
View
3  spec/mizuno_spec.rb
@@ -24,8 +24,7 @@ def post(path, params = nil, headers = {}, body = nil)
before(:all) do
@lock = Mutex.new
@app = Rack::Lint.new(TestApp.new)
- @options = { :host => '127.0.0.1', :port => 9201,
- :embedded => true }
+ @options = { :host => '127.0.0.1', :port => 9201 }
Net::HTTP.version_1_2
Mizuno::HttpServer.run(@app, @options)
end

0 comments on commit e3b6d19

Please sign in to comment.
Something went wrong with that request. Please try again.