From 900a69f585be24dbf3a6885eecbd2aec7f839400 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 23 Apr 2009 19:05:09 -0700 Subject: unicorn_rails: avoid nesting lambdas I've experienced occasional problems with this so it's probably best to stay on the safe side. --- bin/unicorn_rails | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/bin/unicorn_rails b/bin/unicorn_rails index 083e9d8..b3fda7b 100755 --- a/bin/unicorn_rails +++ b/bin/unicorn_rails @@ -114,10 +114,9 @@ end require 'pp' if $DEBUG -# Loads Rails and the private version of Rack it bundles. Returns a -# lambda of arity==0 that will return *another* lambda of arity==1 -# suitable for using inside Rack::Builder.new block. -rails_loader = lambda do || +# this won't run until after forking if preload_app is false +app = lambda do || + # Load Rails and the private version of Rack it bundles. begin require 'config/boot' rescue LoadError => err @@ -128,7 +127,7 @@ rails_loader = lambda do || defined?(::Rails::VERSION::STRING) or abort "Rails::VERSION::STRING not defined by config/boot" - case config + inner_app = case config when nil require 'config/environment' @@ -154,12 +153,8 @@ rails_loader = lambda do || require config Object.const_get(File.basename(config, '.rb').capitalize) end -end -# this won't run until after forking if preload_app is false -app = lambda do || map_path ||= '/' - inner_app = rails_loader.call Rack::Builder.new do if inner_app.class.to_s == "Unicorn::App::OldRails" if map_path != '/' -- cgit v1.2.3-24-ge0c7