diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-03-31 17:10:49 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-03-31 19:00:20 -0700 |
commit | 3adce6a1a803a00cb5cc9da758a10a658aab98ec (patch) | |
tree | 44395cd31f97b15e8f39c6d8f29bdc14a97c5bef /bin/unicorn_rails | |
parent | 7dd3d804e9199a201aa62b7f7e7c28ddeace99c5 (diff) | |
download | unicorn-3adce6a1a803a00cb5cc9da758a10a658aab98ec.tar.gz |
Just use the RAILS_RELATIVE_URL_ROOT variable to support it since probably works on more versions of Rails. Since no application I've ever deployed has ever used it, I'm not going to bother supporting it for Rails <2.3, either.
Diffstat (limited to 'bin/unicorn_rails')
-rwxr-xr-x | bin/unicorn_rails | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/bin/unicorn_rails b/bin/unicorn_rails index 4299fb5..fa0a9b7 100755 --- a/bin/unicorn_rails +++ b/bin/unicorn_rails @@ -81,7 +81,7 @@ opts = OptionParser.new("", 24, ' ') do |opts| opts.on("-P", "--path PATH", "Runs Rails app mounted at a specific path.", "(default: /") do |v| - map_path = v + ENV['RAILS_RELATIVE_URL_ROOT'] = map_path = v end # I'm avoiding Unicorn-specific config options on the command-line. @@ -126,8 +126,12 @@ rails_loader = lambda do || defined?(::Rails::VERSION::STRING) or abort "Rails::VERSION::STRING not defined by config/boot" rescue LoadError => err - abort "#$0 must be run inside RAILS_ROOT=(#{::RAILS_ROOT}) #{err.inspect}" + abort "#$0 must be run inside RAILS_ROOT: #{err.inspect}" end + defined?(::RAILS_ROOT) or abort "RAILS_ROOT not defined by config/boot" + defined?(::RAILS_ENV) or abort "RAILS_ENV not defined by config/boot" + defined?(::Rails::VERSION::STRING) or + abort "Rails::VERSION::STRING not defined by config/boot" case config when nil @@ -166,11 +170,15 @@ app = lambda do || inner_app = rails_loader.call require 'active_support' require 'action_controller' - ActionController::Base.relative_url_root = map_path if map_path map_path ||= '/' inner_app = inner_app.call Rack::Builder.new do if inner_app.class.to_s == "Unicorn::App::OldRails" + if map_path != '/' + # patches + tests welcome, but I really cbf to deal with this + # since all apps I've ever dealt with just use "/" ... + $stderr.puts "relative URL roots may not work for older Rails" + end $stderr.puts "LogTailer not available for Rails < 2.3" unless daemonize $stderr.puts "Debugger not available" if $DEBUG map(map_path) do |