about summary refs log tree commit homepage
path: root/lib/mongrel/rails.rb
diff options
context:
space:
mode:
authorzedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9>2006-03-08 00:52:20 +0000
committerzedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9>2006-03-08 00:52:20 +0000
commit5bf3bca4955c64ad5d2f03c0b717f8924e234830 (patch)
tree6847d0a5ce9b2c7e1f35566b3fec2a95cf9665a5 /lib/mongrel/rails.rb
parentc24a58c9ab3c618f3c96b8374c66fb080081479a (diff)
downloadunicorn-5bf3bca4955c64ad5d2f03c0b717f8924e234830.tar.gz
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@87 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'lib/mongrel/rails.rb')
-rw-r--r--lib/mongrel/rails.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/mongrel/rails.rb b/lib/mongrel/rails.rb
index e55e272..ecff187 100644
--- a/lib/mongrel/rails.rb
+++ b/lib/mongrel/rails.rb
@@ -1,5 +1,6 @@
 require 'mongrel'
-require_gem 'rails'
+require 'cgi'
+
 
 # Implements a handler that can run Rails and serve files out of the
 # Rails application's public directory.  This lets you run your Rails
@@ -23,7 +24,8 @@ require_gem 'rails'
 # An additional feature you can use is
 class RailsHandler < Mongrel::HttpHandler
   attr_reader :files
-
+  attr_reader :guard
+  
   def initialize(dir, mime_map = {})
     @files = Mongrel::DirHandler.new(dir,false)
     @guard = Mutex.new
@@ -52,10 +54,10 @@ class RailsHandler < Mongrel::HttpHandler
       request.params[Mongrel::Const::PATH_INFO] = page_cached
       @files.process(request,response)
     else
-      cgi = Mongrel::CGIWrapper.new(request, response)
-      cgi.handler = self
-
       begin
+        cgi = Mongrel::CGIWrapper.new(request, response)
+        cgi.handler = self
+
         @guard.synchronize do
           # Rails is not thread safe so must be run entirely within synchronize
           Dispatcher.dispatch(cgi, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, response.body)
@@ -72,4 +74,13 @@ class RailsHandler < Mongrel::HttpHandler
     end
   end
 
+
+  def reload!
+    @guard.synchronize do
+      $".replace @orig_dollar_quote
+      GC.start
+      Dispatcher.reset_application!
+      ActionController::Routing::Routes.reload
+    end
+  end
 end