diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-21 17:46:31 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-21 17:46:31 +0000 |
commit | c006bae4b8e0b44fccbd43e2982428aabdeb538e (patch) | |
tree | 58a78cf8a6d51ea71b02a47378daa71a6abf70b1 /railties | |
parent | 32e0138b0ba9acb7405c915f600c789a8c61f44c (diff) | |
download | rails-c006bae4b8e0b44fccbd43e2982428aabdeb538e.tar.gz rails-c006bae4b8e0b44fccbd43e2982428aabdeb538e.tar.bz2 rails-c006bae4b8e0b44fccbd43e2982428aabdeb538e.zip |
Added additional error handling to the FastCGI dispatcher to catch even errors taking down the entire process
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@969 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rwxr-xr-x | railties/dispatches/dispatch.fcgi | 30 |
2 files changed, 20 insertions, 12 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index c8c0fa540a..ce3eabcec6 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added additional error handling to the FastCGI dispatcher to catch even errors taking down the entire process + * Improved the generated scaffold code a lot to take advantage of recent Rails developments #882 [Tobias Luetke] * Combined the script/environment.rb used for gems and regular files version. If vendor/rails/* has all the frameworks, then files version is used, otherwise gems #878 [Nicholas Seckar] diff --git a/railties/dispatches/dispatch.fcgi b/railties/dispatches/dispatch.fcgi index 1c88d902df..ffe5b57812 100755 --- a/railties/dispatches/dispatch.fcgi +++ b/railties/dispatches/dispatch.fcgi @@ -1,20 +1,26 @@ #!/usr/local/bin/ruby -require File.dirname(__FILE__) + "/../config/environment" -require 'dispatcher' -require 'fcgi' +FASTCGI_CRASH_LOG_PATH = "#{RAILS_ROOT}/log/fastcgi.crash.log" -log_file_path = "#{RAILS_ROOT}/log/fastcgi.crash.log" +def dispatcher_error(e, msg = "") + error_message = "[#{Time.now}] Dispatcher failed to catch: #{e} (#{e.class})\n #{e.backtrace.join("\n ")}\n#{msg}" + Logger.new(FASTCGI_CRASH_LOG_PATH).fatal(error_message) +rescue Object => log_error + STDERR << "Couldn't write to #{FASTCGI_CRASH_LOG_PATH} (#{e} [#{e.class}])\n" << error_message +end -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 + require File.dirname(__FILE__) + "/../config/environment" + require 'dispatcher' + require 'fcgi' + + FCGI.each_cgi do |cgi| 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 + Dispatcher.dispatch(cgi) + rescue Object => rails_error + dispatcher_error(rails_error) end end +rescue Object => fcgi_error + dispatcher_error(fcgi_error, "FCGI process #{$$} killed by this error\n") end
\ No newline at end of file |