aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-08-02 00:42:32 -0500
committerJoshua Peek <josh@joshpeek.com>2008-08-04 22:19:41 -0500
commit177a35e711e3b21eac0eb19f03aeae7626e490f5 (patch)
tree4042c7492cc57d79dc6935ffc0677f5f4426740b
parentddd552504bd682d64aa63bd06aa3f74818d48493 (diff)
downloadrails-177a35e711e3b21eac0eb19f03aeae7626e490f5.tar.gz
rails-177a35e711e3b21eac0eb19f03aeae7626e490f5.tar.bz2
rails-177a35e711e3b21eac0eb19f03aeae7626e490f5.zip
Added config.threadsafe! to toggle allow concurrency settings and disable the dependency loader
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/environments/production.rb3
-rw-r--r--railties/lib/initializer.rb12
3 files changed, 17 insertions, 0 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 6df7c568dc..3a276d5aad 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*Edge*
+* Added config.threadsafe! to toggle allow concurrency settings and disable the dependency loader [Josh Peek]
+
* Turn cache_classes on by default [Josh Peek]
* Added configurable eager load paths. Defaults to app/models, app/controllers, and app/helpers [Josh Peek]
diff --git a/railties/environments/production.rb b/railties/environments/production.rb
index e915e8be73..ec5b7bc865 100644
--- a/railties/environments/production.rb
+++ b/railties/environments/production.rb
@@ -4,6 +4,9 @@
# Code is not reloaded between requests
config.cache_classes = true
+# Enable threaded mode
+# config.threadsafe!
+
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index e876481cf1..f8b3a78dff 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -768,6 +768,18 @@ Run `rake gems:install` to install the missing gems.
::RAILS_ROOT.replace @root_path
end
+ # Enable threaded mode. Allows concurrent requests to controller actions and
+ # multiple database connections. Also disables automatic dependency loading
+ # after boot
+ def threadsafe!
+ self.cache_classes = true
+ self.dependency_loading = false
+ self.active_record.allow_concurrency = true
+ self.action_controller.allow_concurrency = true
+ self.to_prepare { Rails.cache.threadsafe! }
+ self
+ end
+
# Loads and returns the contents of the #database_configuration_file. The
# contents of the file are processed via ERB before being sent through
# YAML::load.