mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Generate rackup dispatcher with rails:update:generate_dispatchers
This commit is contained in:
parent
725928854d
commit
61958032d3
5 changed files with 20 additions and 26 deletions
|
@ -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
|
7
railties/dispatches/config.ru
Normal file
7
railties/dispatches/config.ru
Normal file
|
@ -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
|
|
@ -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 }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in a new issue