diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-03-30 01:29:20 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-03-30 01:29:20 -0700 |
commit | aa2208a0574c395cf91ce7ff82e978895aa8b1b7 (patch) | |
tree | 9280035536799aace87da763c088d170c6466d26 /bin/unicorn | |
parent | fa5d9473deaa345e5ca76375fbe21aaae3516b89 (diff) | |
download | unicorn-aa2208a0574c395cf91ce7ff82e978895aa8b1b7.tar.gz |
This allows config.ru to specify listener and stuff before we setup the application.
Diffstat (limited to 'bin/unicorn')
-rwxr-xr-x | bin/unicorn | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/bin/unicorn b/bin/unicorn index da77198..6247f32 100755 --- a/bin/unicorn +++ b/bin/unicorn @@ -105,22 +105,25 @@ opts = OptionParser.new("", 24, ' ') do |opts| opts.parse! ARGV end +config = ARGV[0] || "config.ru" +abort "configuration file #{config} not found" unless File.exist?(config) + +if config =~ /\.ru$/ + # parse embedded command-line options in config.ru comments + if File.open(config, "rb") { |fp| fp.sysread(fp.stat.size) } =~ /^#\\(.*)/ + opts.parse! $1.split(/\s+/) + end +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' -config = ARGV[0] || "config.ru" -abort "configuration file #{config} not found" unless File.exist?(config) - inner_app = case config when /\.ru$/ raw = File.open(config, "rb") { |fp| fp.sysread(fp.stat.size) } - # parse embedded command-line options in config.ru comments - if raw[/^#\\(.*)/] - opts.parse! $1.split(/\s+/) - end lambda { || eval("Rack::Builder.new {(#{raw}\n)}.to_app", nil, config) } else lambda do || |