about summary refs log tree commit homepage
path: root/lib/unicorn.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-04-17 07:33:53 -0700
committerEric Wong <normalperson@yhbt.net>2010-04-19 01:37:46 -0700
commit900628706d6ced43fde614a6fc57f2d2d69e945d (patch)
tree03712b1bf87f2df2b5963524f2b3a64c002e630a /lib/unicorn.rb
parent22e3ed4de0e89b97dac91c95c796eb8a7f93e5de (diff)
downloadunicorn-900628706d6ced43fde614a6fc57f2d2d69e945d.tar.gz
There is no need to be using autoload except for HttpResponse
which depends on Rack (which we want to load as late as
possible).
Diffstat (limited to 'lib/unicorn.rb')
-rw-r--r--lib/unicorn.rb21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index 75ce09d..4fbddc8 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -1,8 +1,17 @@
 # -*- encoding: binary -*-
 
 require 'fcntl'
-require 'unicorn/socket_helper'
 require 'etc'
+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'
 
 # Unicorn module containing all of the classes (include C extensions) for running
@@ -17,12 +26,10 @@ module Unicorn
   class ClientShutdown < EOFError
   end
 
-  autoload :Const, 'unicorn/const'
-  autoload :HttpRequest, 'unicorn/http_request'
+  # 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'
-  autoload :Configurator, 'unicorn/configurator'
-  autoload :TeeInput, 'unicorn/tee_input'
-  autoload :Util, 'unicorn/util'
 
   class << self
     def run(app, options = {})
@@ -808,7 +815,7 @@ module Unicorn
 
         # exploit COW in case of preload_app.  Also avoids race
         # conditions in Rainbows! since load/require are not thread-safe
-        Unicorn.constants.each { |x| Unicorn.const_get(x) }
+        Unicorn.const_get :HttpResponse
       end
     end