Permalink
Browse files

Resurrect threadsafe!

  • Loading branch information...
1 parent 042bd0a commit ce9d9fda77e6b8ca0ac64e528af1892a5d508636 Yehuda Katz + Carl Lerche committed Jun 23, 2009
Showing with 12 additions and 0 deletions.
  1. +12 −0 railties/lib/initializer.rb
@@ -170,6 +170,18 @@ def set_root_path!
RAILS_ROOT.replace self.root_path
end
+ # Enable threaded mode. Allows concurrent requests to controller actions and
+ # multiple database connections. Also disables automatic dependency loading
+ # after boot, and disables reloading code on every request, as these are
+ # fundamentally incompatible with thread safety.
+ def threadsafe!
+ self.preload_frameworks = true
+ self.cache_classes = true
+ self.dependency_loading = false
+ self.action_controller.allow_concurrency = true
+ self
+ end
+
def framework_paths
paths = %w(railties railties/lib activesupport/lib)
paths << 'actionpack/lib' if frameworks.include?(:action_controller) || frameworks.include?(:action_view)

0 comments on commit ce9d9fd

Please sign in to comment.