aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-12-01 12:21:18 -0600
committerJoshua Peek <josh@joshpeek.com>2008-12-01 12:21:18 -0600
commit61958032d3dbb8da8363d02ccda8933b99421fb1 (patch)
treedd52b4c4c42ce50f000457f721879abafe67b1c7
parent725928854d4b6ff5dbafc2bbc95cfade243411a9 (diff)
downloadrails-61958032d3dbb8da8363d02ccda8933b99421fb1.tar.gz
rails-61958032d3dbb8da8363d02ccda8933b99421fb1.tar.bz2
rails-61958032d3dbb8da8363d02ccda8933b99421fb1.zip
Generate rackup dispatcher with rails:update:generate_dispatchers
-rw-r--r--railties/config.ru17
-rw-r--r--railties/dispatches/config.ru7
-rw-r--r--railties/lib/commands/server.rb20
-rw-r--r--railties/lib/rails_generator/generators/applications/app/app_generator.rb1
-rw-r--r--railties/lib/tasks/framework.rake1
5 files changed, 20 insertions, 26 deletions
diff --git a/railties/config.ru b/railties/config.ru
deleted file mode 100644
index 43492a2dcc..0000000000
--- a/railties/config.ru
+++ /dev/null
@@ -1,17 +0,0 @@
-# Rackup Configuration
-#
-# Start Rails mongrel server with rackup
-# $ rackup -p 3000 config.ru
-#
-# Start server with webrick (or any compatible Rack server) instead
-# $ rackup -p 3000 -s webrick config.ru
-
-# Require your environment file to bootstrap Rails
-require File.dirname(__FILE__) + '/config/environment'
-
-# Static server middleware
-# You can remove this extra check if you use an asset server
-use Rails::Rack::Static
-
-# Dispatch the request
-run ActionController::Dispatcher.new
diff --git a/railties/dispatches/config.ru b/railties/dispatches/config.ru
new file mode 100644
index 0000000000..acbfe4e9ae
--- /dev/null
+++ b/railties/dispatches/config.ru
@@ -0,0 +1,7 @@
+# Rack Dispatcher
+
+# Require your environment file to bootstrap Rails
+require File.dirname(__FILE__) + '/config/environment'
+
+# Dispatch the request
+run ActionController::Dispatcher.new
diff --git a/railties/lib/commands/server.rb b/railties/lib/commands/server.rb
index a4bb52592f..3611f80ed3 100644
--- a/railties/lib/commands/server.rb
+++ b/railties/lib/commands/server.rb
@@ -65,7 +65,6 @@ end
ENV["RAILS_ENV"] = options[:environment]
RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV)
-require RAILS_ROOT + "/config/environment"
if File.exist?(options[:config])
config = options[:config]
@@ -74,20 +73,23 @@ if File.exist?(options[:config])
if cfgfile[/^#\\(.*)/]
opts.parse!($1.split(/\s+/))
end
- app = eval("Rack::Builder.new {( " + cfgfile + "\n )}.to_app", nil, config)
+ inner_app = eval("Rack::Builder.new {( " + cfgfile + "\n )}.to_app", nil, config)
else
require config
- app = Object.const_get(File.basename(config, '.rb').capitalize)
+ inner_app = Object.const_get(File.basename(config, '.rb').capitalize)
end
else
- app = Rack::Builder.new {
- use Rails::Rack::Logger
- use Rails::Rack::Static
- use Rails::Rack::Debugger if options[:debugger]
- run ActionController::Dispatcher.new
- }.to_app
+ require RAILS_ROOT + "/config/environment"
end
+inner_app = ActionController::Dispatcher.new
+app = Rack::Builder.new {
+ use Rails::Rack::Logger
+ use Rails::Rack::Static
+ use Rails::Rack::Debugger if options[:debugger]
+ run inner_app
+}.to_app
+
puts "=> Call with -d to detach"
trap(:INT) { exit }
diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb
index fb3a407d2e..4bb94ff96d 100644
--- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb
+++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb
@@ -197,6 +197,7 @@ class AppGenerator < Rails::Generator::Base
if options[:with_dispatchers]
dispatcher_options = { :chmod => 0755, :shebang => options[:shebang] }
+ m.file "dispatches/config.ru", "config.ru"
m.file "dispatches/dispatch.rb", "public/dispatch.rb", dispatcher_options
m.file "dispatches/dispatch.rb", "public/dispatch.cgi", dispatcher_options
m.file "dispatches/dispatch.fcgi", "public/dispatch.fcgi", dispatcher_options
diff --git a/railties/lib/tasks/framework.rake b/railties/lib/tasks/framework.rake
index df080e94ac..d639214ffe 100644
--- a/railties/lib/tasks/framework.rake
+++ b/railties/lib/tasks/framework.rake
@@ -128,6 +128,7 @@ namespace :rails do
desc "Generate dispatcher files in RAILS_ROOT/public"
task :generate_dispatchers do
require 'railties_path'
+ FileUtils.cp(RAILTIES_PATH + '/dispatches/config.ru', RAILS_ROOT + '/config.ru')
FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.fcgi', RAILS_ROOT + '/public/dispatch.fcgi')
FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.rb', RAILS_ROOT + '/public/dispatch.rb')
FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.rb', RAILS_ROOT + '/public/dispatch.cgi')