make sure eventmachine also gets shut down

This commit is contained in:
John Bintz 2012-03-26 11:59:37 -04:00
parent 120010c2b6
commit d4b14f2036
4 changed files with 12 additions and 3 deletions

View File

@ -27,6 +27,7 @@ module Flowerbox
class << self class << self
attr_writer :quiet attr_writer :quiet
attr_accessor :server
def reset! def reset!
@configuration = nil @configuration = nil

View File

@ -5,7 +5,7 @@ module Flowerbox
attr_writer :reporters, :backtrace_filter attr_writer :reporters, :backtrace_filter
attr_accessor :port attr_accessor :port
attr_accessor :test_environment, :runner_environment, :bare_coffeescript, :server attr_accessor :test_environment, :runner_environment, :bare_coffeescript
def spec_patterns def spec_patterns
@spec_patterns ||= [] @spec_patterns ||= []

View File

@ -140,6 +140,7 @@ module Flowerbox
require 'flowerbox/rack' require 'flowerbox/rack'
if Flowerbox.server if Flowerbox.server
Flowerbox.server.runner = self
Flowerbox.server.app.runner = self Flowerbox.server.app.runner = self
Flowerbox.server.app.sprockets = sprockets Flowerbox.server.app.sprockets = sprockets
return Flowerbox.server return Flowerbox.server

View File

@ -10,7 +10,7 @@ module Flowerbox
class Server class Server
attr_reader :options attr_reader :options
attr_reader :runner attr_accessor :runner
class MissingRackApp < StandardError ; end class MissingRackApp < StandardError ; end
class ServerDiedError < StandardError ; end class ServerDiedError < StandardError ; end
@ -83,6 +83,8 @@ module Flowerbox
def stop def stop
if @server_thread if @server_thread
@server_thread[:server].stop rescue nil @server_thread[:server].stop rescue nil
EventMachine.stop_event_loop
@server_thread.kill
wait_for_server_to_stop wait_for_server_to_stop
end end
@ -93,7 +95,12 @@ module Flowerbox
end end
def port def port
return @port if @port ||= options[:port] return @port if @port
if options[:port]
@port = options[:port]
return @port
end
attempts = 20 attempts = 20