lib/mizuno/http_server.rb in mizuno-0.4.0 vs lib/mizuno/http_server.rb in mizuno-0.4.1

- old
+ new

@@ -66,25 +66,33 @@ # Add the context to the server and start. @server.set_handler(context) puts "Listening on #{connector.getHost}:#{connector.getPort}" @server.start + # If we're embeded, we're done. + return if options[:embedded] + # Stop the server when we get The Signal. trap("SIGINT") { @server.stop and exit } # 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] + @server.join end # # Shuts down an embedded Jetty instance. # def self.stop + return unless @server + puts "Stopping Jetty..." @server.stop end end end # Register ourselves with Rack when this file gets loaded. Rack::Handler.register 'mizuno', 'Mizuno::HttpServer' + +# Ensure that we shutdown the server on exit. +at_exit { Mizuno::HttpServer.stop }