aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorChris Cherry <ctcherry@gmail.com>2009-02-05 15:19:40 -0600
committerJoshua Peek <josh@joshpeek.com>2009-02-05 15:19:40 -0600
commitb6e7a76cc573ee35c1df648f35d5865672f55e15 (patch)
treed5c58e22246760fecd3a9c1c30ccbc5b717c1e6b /railties/lib
parent4866ce45d0ab66a1b237c55e21be730de282b059 (diff)
downloadrails-b6e7a76cc573ee35c1df648f35d5865672f55e15.tar.gz
rails-b6e7a76cc573ee35c1df648f35d5865672f55e15.tar.bz2
rails-b6e7a76cc573ee35c1df648f35d5865672f55e15.zip
script/server command can accept --path option to set app's root path [#1156 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/commands/server.rb19
1 files changed, 15 insertions, 4 deletions
diff --git a/railties/lib/commands/server.rb b/railties/lib/commands/server.rb
index 43b18004c0..ebe34a42cd 100644
--- a/railties/lib/commands/server.rb
+++ b/railties/lib/commands/server.rb
@@ -17,7 +17,8 @@ options = {
:environment => (ENV['RAILS_ENV'] || "development").dup,
:config => RAILS_ROOT + "/config.ru",
:detach => false,
- :debugger => false
+ :debugger => false,
+ :path => nil
}
ARGV.clone.options do |opts|
@@ -32,6 +33,7 @@ ARGV.clone.options do |opts|
opts.on("-e", "--environment=name", String,
"Specifies the environment to run this server under (test/development/production).",
"Default: development") { |v| options[:environment] = v }
+ opts.on("-P", "--path=/path", String, "Runs Rails app mounted at a specific path.", "Default: /") { |v| options[:path] = v }
opts.separator ""
@@ -50,7 +52,7 @@ unless server
end
puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}"
-puts "=> Rails #{Rails.version} application starting on http://#{options[:Host]}:#{options[:Port]}"
+puts "=> Rails #{Rails.version} application starting on http://#{options[:Host]}:#{options[:Port]}#{options[:path]}"
%w(cache pids sessions sockets).each do |dir_to_make|
FileUtils.mkdir_p(File.join(RAILS_ROOT, 'tmp', dir_to_make))
@@ -83,11 +85,20 @@ else
inner_app = ActionController::Dispatcher.new
end
+if options[:path].nil?
+ map_path = "/"
+else
+ ActionController::Base.relative_url_root = options[:path]
+ map_path = options[:path]
+end
+
app = Rack::Builder.new {
use Rails::Rack::LogTailer unless options[:detach]
- use Rails::Rack::Static
use Rails::Rack::Debugger if options[:debugger]
- run inner_app
+ map map_path do
+ use Rails::Rack::Static
+ run inner_app
+ end
}.to_app
puts "=> Call with -d to detach"