提交 104f3a57 编写于 作者: J Jeremy Kemper

Add config.preload_frameworks to load all frameworks at startup. Default to...

Add config.preload_frameworks to load all frameworks at startup. Default to false so Rails autoloads itself as it's used.
上级 d01f75b1
......@@ -57,5 +57,3 @@ module Net
autoload :MailHelper, 'action_mailer/mail_helper'
autoload :TMail, 'action_mailer/vendor/tmail'
ActionMailer.load_all! unless ENV['LAZY']
......@@ -100,5 +100,3 @@ class Session
autoload :HTML, 'action_controller/vendor/html-scanner'
autoload :Rack, 'action_controller/vendor/rack'
ActionController.load_all! unless ENV['LAZY']
......@@ -55,5 +55,3 @@ class ERB
end
I18n.load_path << "#{File.dirname(__FILE__)}/action_view/locale/en.yml"
ActionView.load_all! unless ENV['LAZY']
......@@ -75,5 +75,3 @@ module ConnectionAdapters
require 'active_record/i18n_interpolation_deprecation'
I18n.load_path << File.dirname(__FILE__) + '/active_record/locale/en.yml'
ActiveRecord.load_all! unless ENV['LAZY']
......@@ -55,5 +55,3 @@ def self.load_all!
require 'active_support/json'
I18n.load_path << "#{File.dirname(__FILE__)}/active_support/locale/en.yml"
ActiveSupport.load_all! unless ENV['LAZY']
*2.3.0 [Edge]*
* Add config.preload_frameworks to load all frameworks at startup. Default to false so Rails autoloads itself as it's used. Turn this on for Passenger and JRuby. Also turned on by config.threadsafe! [Jeremy Kemper]
* Add a rake task to generate dispatchers : rake rails:generate_dispatchers [Pratik]
* "rails <app>" will not generate public/dispatch.cgi/fcgi/rb files by default now. Please use "--with-dispatchers" option if you need them. [Yaroslav Markin, Pratik Naik]
......
......@@ -136,6 +136,7 @@ def process
add_gem_load_paths
require_frameworks
preload_frameworks
set_autoload_paths
add_plugin_load_paths
load_environment
......@@ -264,6 +265,19 @@ def require_frameworks
raise e.to_s
end
# Preload all frameworks specified by the Configuration#frameworks.
# Used by Passenger to ensure everything's loaded before forking and
# to avoid autoload race conditions in JRuby.
def preload_frameworks
if configuration.preload_frameworks
configuration.frameworks.each do |framework|
# String#classify and #constantize aren't available yet.
toplevel = Object.const_get(framework.to_s.gsub(/(?:^|_)(.)/) { $1.upcase })
toplevel.load_all!
end
end
end
# Add the load paths used by support functions such as the info controller
def add_support_load_paths
end
......@@ -602,6 +616,9 @@ class Configuration
# A stub for setting options on ActiveSupport.
attr_accessor :active_support
# Whether to preload all frameworks at startup.
attr_accessor :preload_frameworks
# Whether or not classes should be cached (set to false if you want
# application classes to be reloaded on each request)
attr_accessor :cache_classes
......@@ -768,6 +785,7 @@ def initialize
self.log_level = default_log_level
self.view_path = default_view_path
self.controller_paths = default_controller_paths
self.preload_frameworks = default_preload_frameworks
self.cache_classes = default_cache_classes
self.dependency_loading = default_dependency_loading
self.whiny_nils = default_whiny_nils
......@@ -810,6 +828,7 @@ def set_root_path!
# multiple database connections. Also disables automatic dependency loading
# after boot
def threadsafe!
self.preload_frameworks = true
self.cache_classes = true
self.dependency_loading = false
self.action_controller.allow_concurrency = true
......@@ -955,6 +974,10 @@ def default_dependency_loading
true
end
def default_preload_frameworks
false
end
def default_cache_classes
true
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册