bin/mongrel_rails in mongrel-0.3.9 vs bin/mongrel_rails in mongrel-0.3.10

- old
+ new

@@ -1,11 +1,10 @@ require 'rubygems' -require 'mongrel/rails' require 'yaml' +require 'mongrel' - class Start < GemPlugin::Plugin "/commands" include Mongrel::Command::Base def configure options [ @@ -70,12 +69,17 @@ return mime end def configure_rails + # need this later for safe reloading + $orig_dollar_quote = $".clone + ENV['RAILS_ENV'] = @environment require 'config/environment' + require 'dispatcher' + require 'mongrel/rails' # configure the rails handler rails = RailsHandler.new(@docroot, load_mime_map) return rails @@ -85,38 +89,40 @@ @restart = false 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/ # graceful shutdown trap("TERM") { server.stop + File.unlink @pid_file if File.exist?(@pid_file) } # rails reload trap("HUP") { - server.stop - @restart = true + STDERR.puts "Reloading rails..." + rails.reload! + STDERR.puts "Done reloading rails." } # restart trap("USR2") { server.stop + File.unlink @pid_file if File.exist?(@pid_file) @restart = true } end # hook up any rails specific plugins GemPlugin::Manager.instance.load "mongrel" => GemPlugin::INCLUDE begin + # start mongrel processing thread + server.run STDERR.puts "Server ready." server.acceptor.join rescue Interrupt STDERR.puts "Interrupted." raise @@ -173,12 +179,10 @@ if @force send_signal("KILL", @pid_file) else send_signal("TERM", @pid_file) end - - File.unlink(@pid_file) end end @@ -208,11 +212,9 @@ if @soft send_signal("HUP", @pid_file) else send_signal("USR2", @pid_file) end - - File.unlink(@pid_file) end end GemPlugin::Manager.instance.load "mongrel" => GemPlugin::INCLUDE, "rails" => GemPlugin::EXCLUDE