about summary refs log tree commit homepage
path: root/bin
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 /bin
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 'bin')
-rw-r--r--bin/mongrel_rails15
1 files changed, 10 insertions, 5 deletions
diff --git a/bin/mongrel_rails b/bin/mongrel_rails
index 294a41c..bc2aac4 100644
--- a/bin/mongrel_rails
+++ b/bin/mongrel_rails
@@ -72,8 +72,13 @@ class Start < GemPlugin::Plugin "/commands"
   end
 
   def configure_rails
+    # need this later for safe reloading
+    @orig_dollar_quote = $".clone
+
     ENV['RAILS_ENV'] = @environment
     require 'config/environment'
+    require 'dispatcher'
+    require 'cgi'
 
     # configure the rails handler
     rails = RailsHandler.new(@docroot, load_mime_map)
@@ -87,9 +92,6 @@ class Start < GemPlugin::Plugin "/commands"
     server = Mongrel::HttpServer.new(@address, @port, @num_procs.to_i, @timeout.to_i)
     server.register("/", rails)
 
-    # start mongrel processing thread
-    server.run
-
     # signal trapping just applies to posix systems
     # TERM is a valid signal, but still doesn't gracefuly shutdown on win32.
     if RUBY_PLATFORM !~ /mswin/
@@ -100,8 +102,9 @@ class Start < GemPlugin::Plugin "/commands"
 
       # rails reload
       trap("HUP") {
-        server.stop
-        @restart = true
+        STDERR.puts "Reloading rails..."
+        rails.reload!
+        STDERR.puts "Done reloading rails."
       }
 
       # restart
@@ -115,6 +118,8 @@ class Start < GemPlugin::Plugin "/commands"
     GemPlugin::Manager.instance.load "mongrel" => GemPlugin::INCLUDE
 
     begin
+      # start mongrel processing thread
+      server.run
       STDERR.puts "Server ready."
       server.acceptor.join
     rescue Interrupt