about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-04-02 10:42:08 -0700
committerEric Wong <normalperson@yhbt.net>2009-04-02 10:43:52 -0700
commit03f3d6d452aff584f050c5789180324e5fef4751 (patch)
tree20c2dd578f366b435283e9ce1343d45136a96aa8
parent61979637d7cace5c7871d621397b318f8151b743 (diff)
downloadunicorn-03f3d6d452aff584f050c5789180324e5fef4751.tar.gz
We can get by with one less lambda in the loader
-rwxr-xr-xbin/unicorn40
1 files changed, 17 insertions, 23 deletions
diff --git a/bin/unicorn b/bin/unicorn
index 6247f32..a34d9bc 100755
--- a/bin/unicorn
+++ b/bin/unicorn
@@ -117,40 +117,35 @@ end
 
 require 'pp' if $DEBUG
 
-# require Rack as late as possible in case $LOAD_PATH is modified
-# in config.ru or command-line
-require 'rack'
-
-inner_app = case config
-when /\.ru$/
-  raw = File.open(config, "rb") { |fp| fp.sysread(fp.stat.size) }
-  lambda { || eval("Rack::Builder.new {(#{raw}\n)}.to_app", nil, config) }
-else
-  lambda do ||
+app = lambda do ||
+  # require Rack as late as possible in case $LOAD_PATH is modified
+  # in config.ru or command-line
+  require 'rack'
+  inner_app = case config
+  when /\.ru$/
+    raw = File.open(config, "rb") { |fp| fp.sysread(fp.stat.size) }
+    eval("Rack::Builder.new {(#{raw}\n)}.to_app", nil, config)
+  else
     require config
     Object.const_get(File.basename(config, '.rb').capitalize)
   end
-end
-
-app = case env
-when "development"
-  lambda do ||
+  pp({ :inner_app => inner_app }) if $DEBUG
+  case env
+  when "development"
     Rack::Builder.new do
       use Rack::CommonLogger, $stderr
       use Rack::ShowExceptions
       use Rack::Lint
-      run inner_app.call
+      run inner_app
     end.to_app
-  end
-when "deployment"
-  lambda do ||
+  when "deployment"
     Rack::Builder.new do
       use Rack::CommonLogger, $stderr
-      run inner_app.call
+      run inner_app
     end.to_app
+  else
+    inner_app
   end
-else
-  inner_app
 end
 
 listeners << "#{host}:#{port}" if set_listener
@@ -159,7 +154,6 @@ if $DEBUG
   pp({
     :unicorn_options => options,
     :app => app,
-    :inner_app => inner_app,
     :daemonize => daemonize,
   })
 end