2004-11-23 20:04:44 -05:00
|
|
|
#!/usr/local/bin/ruby
|
|
|
|
|
2005-03-22 19:54:05 -05:00
|
|
|
def dispatcher_error(path,e,msg="")
|
|
|
|
error_message =
|
|
|
|
"[#{Time.now}] Dispatcher failed to catch: #{e} (#{e.class})\n #{e.backtrace.join("\n ")}\n#{msg}"
|
|
|
|
Logger.new(path).fatal(error_message)
|
2005-03-21 12:46:31 -05:00
|
|
|
rescue Object => log_error
|
2005-03-22 19:54:05 -05:00
|
|
|
STDERR << "Couldn't write to #{path} (#{e} [#{e.class}])\n" << error_message
|
2005-03-21 12:46:31 -05:00
|
|
|
end
|
2005-03-04 07:12:55 -05:00
|
|
|
|
2005-03-21 12:46:31 -05:00
|
|
|
begin
|
|
|
|
require File.dirname(__FILE__) + "/../config/environment"
|
|
|
|
require 'dispatcher'
|
|
|
|
require 'fcgi'
|
|
|
|
|
2005-03-22 19:54:05 -05:00
|
|
|
log_file_path = "#{RAILS_ROOT}/log/fastcgi.crash.log"
|
|
|
|
|
2005-03-21 12:46:31 -05:00
|
|
|
FCGI.each_cgi do |cgi|
|
2005-03-04 07:12:55 -05:00
|
|
|
begin
|
2005-03-21 12:46:31 -05:00
|
|
|
Dispatcher.dispatch(cgi)
|
|
|
|
rescue Object => rails_error
|
2005-03-22 19:54:05 -05:00
|
|
|
dispatcher_error(log_file_path, rails_error)
|
2005-03-04 07:12:55 -05:00
|
|
|
end
|
|
|
|
end
|
2005-03-21 12:46:31 -05:00
|
|
|
rescue Object => fcgi_error
|
2005-03-22 19:54:05 -05:00
|
|
|
dispatcher_error(log_file_path, fcgi_error, "FCGI process #{$$} killed by this error\n")
|
2005-03-04 07:12:55 -05:00
|
|
|
end
|