From 86c544aa864ad8d0ef65ef43c9e765eb4d37a4ab Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 6 May 2010 19:05:13 +0000 Subject: always load Rack up front at startup It's too complicated and error-prone to allow apps to use a different version of Rack than the one Unicorn would otherwise use by default. If an app requires a different version of Rack than what Unicorn would load by default, it is recommended they only install that version of Rack (and no others) since Unicorn does not have any strict requirements on currently released Rack versions. If it is not possible to only have one Rack version installed globally, then they should either use Isolate or Bundler and install a private version of Unicorn along with their preferred version of Rack. Users who install in this way are recommended to execute the isolated/bundled version of Unicorn, instead of what would normally be in $PATH. Feedback/tips to mailto:mongrel-unicorn@rubyforge.org from Isolate and Bundler users would be greatly appreciated. --- lib/unicorn.rb | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/lib/unicorn.rb b/lib/unicorn.rb index 14e0e52..70222f4 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -2,17 +2,14 @@ require 'fcntl' require 'etc' +require 'rack' require 'unicorn/socket_helper' require 'unicorn/const' require 'unicorn/http_request' require 'unicorn/configurator' require 'unicorn/util' require 'unicorn/tee_input' - -# autoload this so the app can prefer a different version, we -# don't rely on Rack itself for much and should be compatible for -# 1.0.x and 1.1.x+ -autoload :Rack, 'rack' +require 'unicorn/http_response' # Unicorn module containing all of the classes (include C extensions) for running # a Unicorn web server. It contains a minimalist HTTP server with just enough @@ -26,11 +23,6 @@ module Unicorn class ClientShutdown < EOFError end - # we load HttpResponse last since it depends on Rack, and we - # want the application to be able to specify Rack (if they're - # *not* using config.ru) - autoload :HttpResponse, 'unicorn/http_response' - class << self def run(app, options = {}) HttpServer.new(app, options).start.join @@ -822,10 +814,6 @@ module Unicorn Gem.refresh end self.app = app.call - - # exploit COW in case of preload_app. Also avoids race - # conditions in Rainbows! since load/require are not thread-safe - Unicorn.const_get :HttpResponse end end -- cgit v1.2.3-24-ge0c7