Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Generate rackup dispatcher with rails:update:generate_dispatchers

  • Loading branch information...
commit 61958032d3dbb8da8363d02ccda8933b99421fb1 1 parent 7259288
@josh josh authored
View
17 railties/config.ru
@@ -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
View
7 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
View
20 railties/lib/commands/server.rb
@@ -65,7 +65,6 @@
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 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 }
View
1  railties/lib/rails_generator/generators/applications/app/app_generator.rb
@@ -197,6 +197,7 @@ def create_dispatch_files(m)
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
View
1  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')
Please sign in to comment.
Something went wrong with that request. Please try again.