From 706cc445863ff99d8605257a43e7bbd633c604c8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 28 Feb 2010 18:48:59 -0800 Subject: put switch parsing for config.ru into Unicorn.builder This lets us reuse code for Zbatery and Rainbows!, too. --- lib/unicorn.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib') 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$/ -- cgit v1.2.3-24-ge0c7