-
Notifications
You must be signed in to change notification settings - Fork 5
ActionMailerCheck: Support :sendmail and :test #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,11 +14,34 @@ def initialize(klass = ActionMailer::Base, timeout = 5) | |
|
|
||
| # Public: Return the status of the check | ||
| def check | ||
| tcp_socket_request | ||
| mark_message "#{klass} check to #{host}:#{port} successful" | ||
| rescue => e | ||
| mark_message "#{klass} at #{host}:#{port} is not accepting connections: '#{e}'" | ||
| mark_failure | ||
| case klass.delivery_method | ||
| when :smtp | ||
| begin | ||
| tcp_socket_request | ||
| mark_message "#{klass} check to #{host}:#{port} successful" | ||
| rescue => e | ||
| mark_message "#{klass} at #{host}:#{port} is not accepting connections: '#{e}'" | ||
| mark_failure | ||
| end | ||
| when :sendmail | ||
| begin | ||
| location = klass.sendmail_settings[:location] | ||
| if File.executable?(location) | ||
| mark_message "#{klass} sendmail executable #{location} can be executed" | ||
| else | ||
| mark_message "#{klass} sendmail executable #{location} is not executable" | ||
| mark_failure | ||
| end | ||
| rescue => e | ||
| mark_message "#{klass} error checking sendmail executable: '#{e}'" | ||
| mark_failure | ||
| end | ||
| when :test | ||
| mark_message "#{klass} is in test mode" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed and changed in latest revision. |
||
| else | ||
| mark_message "unknown delivery method #{klass.delivery_method}" | ||
| mark_failure | ||
| end | ||
| end | ||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
:sendmailbranch has no exception handling, unlike:smtpwhich keeps the originalbegin/rescue. Ifsendmail_settings[:location]is nil (a realistic misconfiguration — e.g. an app setssendmail_settings = { arguments: [...] }without:location),File.executable?(nil)raises aTypeError. I reproduced this live, and it propagates unrescued throughCheck#runandCheckCollection(bothcheck_in_sequenceandcheck_in_parallel, sinceThread#joinre-raises), crashing the health-check endpoint instead of reporting a graceful failure. Worth wrapping this in abegin/rescuelike the:smtpbranch.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exceptions are handled in the latest revision.