about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-02-28 18:48:59 -0800
committerEric Wong <normalperson@yhbt.net>2010-02-28 18:48:59 -0800
commit706cc445863ff99d8605257a43e7bbd633c604c8 (patch)
tree143bb3dc99493a5ee5bf61bce87a4880a0203cb4
parenta31af29a22cb22072828391d8f421ccf6c59d9b5 (diff)
downloadunicorn-706cc445863ff99d8605257a43e7bbd633c604c8.tar.gz
This lets us reuse code for Zbatery and Rainbows!, too.
-rwxr-xr-xbin/unicorn9
-rw-r--r--lib/unicorn.rb9
2 files changed, 9 insertions, 9 deletions
diff --git a/bin/unicorn b/bin/unicorn
index 0da0869..7c65590 100755
--- a/bin/unicorn
+++ b/bin/unicorn
@@ -111,16 +111,9 @@ end
 ru = ARGV[0] || "config.ru"
 abort "configuration file #{ru} not found" unless File.exist?(ru)
 
-if ru =~ /\.ru$/
-  # parse embedded command-line options in config.ru comments
-  if File.open(ru, "rb") { |fp| fp.sysread(fp.stat.size) } =~ /^#\\(.*)/
-    opts.parse! $1.split(/\s+/)
-  end
-end
-
+app = Unicorn.builder(ru, opts)
 require 'pp' if $DEBUG
 
-app = Unicorn.builder(ru)
 listeners << "#{host}:#{port}" if set_listener
 
 if $DEBUG
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index d3e9c3d..43ef9e8 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -32,7 +32,14 @@ module Unicorn
     # app (which we defer based on the outcome of "preload_app" in the
     # Unicorn config).  The returned lambda will be called when it is
     # time to build the app.
-    def builder(ru)
+    def builder(ru, opts)
+      if ru =~ /\.ru\z/
+        # parse embedded command-line options in config.ru comments
+        if File.open(ru, "rb") { |fp| fp.sysread(fp.stat.size) } =~ /^#\\(.*)/
+          opts.parse! $1.split(/\s+/)
+        end
+      end
+
       lambda do ||
         inner_app = case ru
         when /\.ru$/