ExceptionNotifiable: failure when memory low
Reported by Stephan Wehner | July 18th, 2008 @ 12:07 AM
ExceptionNotifiable can fail when memory is low, so that no email is sent; instead, another exception is raised.
ExceptionNotifiable spawns a sub-process to determine the hostname, which can be expensive.
To fix this, determine the value by using Socket.gethostname.
Below is a patch (also attached) to fix this. Note that Socket.gethostname may contain domain information whereas the original code uses the '-s' switch which strips domain information. Not sure why the switch was added.
Index: lib/exception_notifier_helper.rb
===================================================================
--- lib/exception_notifier_helper.rb (revision 36)
+++ lib/exception_notifier_helper.rb (working copy)
@@ -1,4 +1,5 @@
require 'pp'
+require 'socket'
- Copyright (c) 2005 Jamis Buck
#
@@ -60,4 +61,8 @@
def object_to_yaml(object)
object.to_yaml.sub(/^---\s*/m, "")
end
+
- def hostname
- Socket.gethostname rescue 'hostname.not.available'
- end
end
Index: views/exception_notifier/_environment.rhtml
===================================================================
--- views/exception_notifier/_environment.rhtml (revision 36)
+++ views/exception_notifier/_environment.rhtml (working copy)
@@ -4,4 +4,4 @@
<% end -%>
- Process: <%= $$ %>
-* Server : <%= `hostname -s`.chomp %>
+* Server : <%= hostname %>
Comments and changes to this ticket
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
