Class: OkComputer::ActionMailerCheck
- Defined in:
- lib/ok_computer/built_in_checks/action_mailer_check.rb
Overview
Verifies if the mail server configured for ActionMailer is responding.
Constant Summary
Constants inherited from PingCheck
Constants inherited from Check
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#port ⇒ Object
Returns the value of attribute port.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Attributes inherited from PingCheck
Attributes inherited from Check
#failure_occurred, #message, #registrant_name, #skip_all, #time
Instance Method Summary collapse
-
#check ⇒ Object
Public: Return the status of the check.
-
#initialize(klass = ActionMailer::Base, timeout = 5) ⇒ ActionMailerCheck
constructor
A new instance of ActionMailerCheck.
Methods inherited from Check
#<=>, #clear, #mark_failure, #mark_message, #run, #success?, #to_json, #to_text, #with_benchmarking
Constructor Details
#initialize(klass = ActionMailer::Base, timeout = 5) ⇒ ActionMailerCheck
Returns a new instance of ActionMailerCheck.
7 8 9 10 11 12 13 |
# File 'lib/ok_computer/built_in_checks/action_mailer_check.rb', line 7 def initialize(klass = ActionMailer::Base, timeout = 5) self.klass = klass self.timeout = timeout host = klass.smtp_settings[:address] port = klass.smtp_settings[:port] || 25 super(host, port, timeout) end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/ok_computer/built_in_checks/action_mailer_check.rb', line 5 def host @host end |
#klass ⇒ Object
Returns the value of attribute klass.
5 6 7 |
# File 'lib/ok_computer/built_in_checks/action_mailer_check.rb', line 5 def klass @klass end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/ok_computer/built_in_checks/action_mailer_check.rb', line 5 def port @port end |
#timeout ⇒ Object
Returns the value of attribute timeout.
5 6 7 |
# File 'lib/ok_computer/built_in_checks/action_mailer_check.rb', line 5 def timeout @timeout end |
Instance Method Details
#check ⇒ Object
Public: Return the status of the check
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ok_computer/built_in_checks/action_mailer_check.rb', line 16 def check case klass.delivery_method when :smtp begin tcp_socket_request "#{klass} check to #{host}:#{port} successful" rescue => e "#{klass} at #{host}:#{port} is not accepting connections: '#{e}'" mark_failure end when :sendmail begin location = klass.sendmail_settings[:location] if File.executable?(location) "#{klass} sendmail executable #{location} can be executed" else "#{klass} sendmail executable #{location} is not executable" mark_failure end rescue => e "#{klass} error checking sendmail executable: '#{e}'" mark_failure end when :test "#{klass} is in test mode" else "unknown delivery method #{klass.delivery_method}" mark_failure end end |