aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--railties/CHANGELOG2
-rwxr-xr-xrailties/dispatches/dispatch.fcgi15
2 files changed, 16 insertions, 1 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index fa639af992..7e0a4311f0 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Added begin/rescue around the FCGI dispatcher so no uncaught exceptions can bubble up to kill the process (logs to log/fastcgi.crash.log)
+
* Fixed that association#count would produce invalid sql when called sequentialy #659 [kanis@comcard.de]
* Fixed test/mocks/testing to the correct test/mocks/test #740
diff --git a/railties/dispatches/dispatch.fcgi b/railties/dispatches/dispatch.fcgi
index 0f1b9b3a4b..1c88d902df 100755
--- a/railties/dispatches/dispatch.fcgi
+++ b/railties/dispatches/dispatch.fcgi
@@ -4,4 +4,17 @@ require File.dirname(__FILE__) + "/../config/environment"
require 'dispatcher'
require 'fcgi'
-FCGI.each_cgi { |cgi| Dispatcher.dispatch(cgi) } \ No newline at end of file
+log_file_path = "#{RAILS_ROOT}/log/fastcgi.crash.log"
+
+FCGI.each_cgi do |cgi|
+ begin
+ Dispatcher.dispatch(cgi)
+ rescue Object => e
+ error_message = "[#{Time.now}] Dispatcher failed to catch: #{e} (#{e.class})\n #{e.backtrace.join("\n ")}\n"
+ begin
+ Logger.new(log_file_path).fatal(error_message)
+ rescue Object => log_error
+ STDERR << "Couldn't write to #{log_file_path} (#{log_error} [#{log_error.class}])\n" << error_message
+ end
+ end
+end \ No newline at end of file