about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--bin/mongrel_rails10
-rw-r--r--lib/mongrel/configurator.rb6
2 files changed, 14 insertions, 2 deletions
diff --git a/bin/mongrel_rails b/bin/mongrel_rails
index e5b5248..d96dc5d 100644
--- a/bin/mongrel_rails
+++ b/bin/mongrel_rails
@@ -139,7 +139,15 @@ module Mongrel
         if RUBY_PLATFORM !~ /mswin/
           cmd = "ruby #{__FILE__} start #{original_args.join(' ')}"
           config.log "Restarting with arguments:  #{cmd}"
-          exec cmd
+          config.stop
+          config.remove_pid_file
+
+          if config.defaults[:daemon]
+            system cmd
+          else
+            STDERR.puts "Can't restart unless in daemon mode."
+            exit 1
+          end
         else
           config.log "Win32 does not support restarts. Exiting."
         end
diff --git a/lib/mongrel/configurator.rb b/lib/mongrel/configurator.rb
index dd21e65..5f71f3f 100644
--- a/lib/mongrel/configurator.rb
+++ b/lib/mongrel/configurator.rb
@@ -70,6 +70,10 @@ module Mongrel
       end
     end
 
+    def remove_pid_file
+      File.unlink(@pid_file) if @pid_file and File.exists?(@pid_file)
+    end
+
     # Writes the PID file but only if we're on windows.
     def write_pid_file
       if RUBY_PLATFORM !~ /mswin/
@@ -350,7 +354,7 @@ module Mongrel
       trap("INT") { log "INT signal received."; stop(false) }
 
       # clean up the pid file always
-      at_exit { File.unlink(@pid_file) if @pid_file and File.exists?(@pid_file) }
+      at_exit { remove_pid_file }
 
       if RUBY_PLATFORM !~ /mswin/
         # graceful shutdown