From 723254df772154e2790b26923d4827a096c53428 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 1 Mar 2009 14:43:04 -0800 Subject: Begin to allow deferred app creation/loading Some applications do not handle loading before forking out-of-the-box very gracefully, this starts adding support to build the Rack(-ish) application later in the process. --- lib/unicorn.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/unicorn.rb') diff --git a/lib/unicorn.rb b/lib/unicorn.rb index aad4c3d..fa2ebe8 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -86,6 +86,7 @@ module Unicorn config_listeners.each { |addr| listen(addr) } listen(Const::DEFAULT_LISTENER) if @listeners.empty? self.pid = @config[:pid] + build_app! spawn_missing_workers self end @@ -529,5 +530,9 @@ module Unicorn listeners.map { |io| sock_name(io) } end + def build_app! + @app = @app.call if @app.respond_to?(:arity) && @app.arity == 0 + end + end end -- cgit v1.2.3-24-ge0c7