mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Fallback to WEBRick if Mongrel is unavailable (JRuby)
This commit is contained in:
parent
18185c4627
commit
c5d0de9b94
1 changed files with 11 additions and 3 deletions
|
@ -1,7 +1,11 @@
|
||||||
require 'uri'
|
require 'uri'
|
||||||
require 'net/http'
|
require 'net/http'
|
||||||
require 'rack'
|
require 'rack'
|
||||||
require 'rack/handler/mongrel'
|
begin
|
||||||
|
require 'rack/handler/mongrel'
|
||||||
|
rescue LoadError
|
||||||
|
require 'rack/handler/webrick'
|
||||||
|
end
|
||||||
|
|
||||||
class Capybara::Server
|
class Capybara::Server
|
||||||
class Identify
|
class Identify
|
||||||
|
@ -10,7 +14,7 @@ class Capybara::Server
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
if env["REQUEST_PATH"] == "/__identify__"
|
if env["PATH_INFO"] == "/__identify__"
|
||||||
[200, {}, @app.object_id.to_s]
|
[200, {}, @app.object_id.to_s]
|
||||||
else
|
else
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
|
@ -48,7 +52,11 @@ private
|
||||||
|
|
||||||
Timeout.timeout(10) do
|
Timeout.timeout(10) do
|
||||||
Thread.new do
|
Thread.new do
|
||||||
Rack::Handler::Mongrel.run Identify.new(@app), :Port => port
|
if defined?(Rack::Handler::Mongrel)
|
||||||
|
Rack::Handler::Mongrel.run(Identify.new(@app), :Port => port)
|
||||||
|
else
|
||||||
|
Rack::Handler::WEBrick.run(Identify.new(@app), :Port => port, :AccessLog => [])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
Capybara.log "checking if application has booted"
|
Capybara.log "checking if application has booted"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue