Commit d77120befa7f3861e2861c92965cdb6bb9008793
Committed by
Rodrigo Souto
1 parent
2076b9e3
Exists in
master
and in
29 other branches
Show object in exceptions notification of feed-updater and delayed_job
Showing
2 changed files
with
26 additions
and
9 deletions
Show diff stats
lib/feed_updater.rb
@@ -20,14 +20,20 @@ end | @@ -20,14 +20,20 @@ end | ||
20 | class FeedUpdater | 20 | class FeedUpdater |
21 | 21 | ||
22 | class ExceptionNotification < ActionMailer::Base | 22 | class ExceptionNotification < ActionMailer::Base |
23 | - def mail error | 23 | + def mail container, error |
24 | environment = Environment.default | 24 | environment = Environment.default |
25 | 25 | ||
26 | recipients NOOSFERO_CONF['exception_recipients'] | 26 | recipients NOOSFERO_CONF['exception_recipients'] |
27 | from environment.contact_email | 27 | from environment.contact_email |
28 | reply_to environment.contact_email | 28 | reply_to environment.contact_email |
29 | subject "[#{environment.name}] Feed-updater: #{error.message}" | 29 | subject "[#{environment.name}] Feed-updater: #{error.message}" |
30 | - body render(:text => error.backtrace.join("\n")) | 30 | + body render(:text => " |
31 | +Container: | ||
32 | +#{container.inspect} | ||
33 | + | ||
34 | +Backtrace: | ||
35 | +#{error.backtrace.join("\n")} | ||
36 | + ") | ||
31 | end | 37 | end |
32 | end | 38 | end |
33 | 39 | ||
@@ -88,11 +94,13 @@ class FeedUpdater | @@ -88,11 +94,13 @@ class FeedUpdater | ||
88 | if !running | 94 | if !running |
89 | break | 95 | break |
90 | end | 96 | end |
91 | - feed_handler.process(container) | 97 | + begin |
98 | + feed_handler.process(container) | ||
99 | + rescue Exception => e | ||
100 | + FeedUpdater::ExceptionNotification.deliver_mail container, e if NOOSFERO_CONF['exception_recipients'].present? | ||
101 | + end | ||
92 | end | 102 | end |
93 | end | 103 | end |
94 | - rescue Exception => e | ||
95 | - FeedUpdater::ExceptionNotification.deliver_mail e if NOOSFERO_CONF['exception_recipients'].present? | ||
96 | end | 104 | end |
97 | end | 105 | end |
98 | 106 |
vendor/plugins/monkey_patches/rescue_delayed_job_crashes/init.rb
1 | Delayed::Worker.module_eval do | 1 | Delayed::Worker.module_eval do |
2 | # based on https://groups.google.com/forum/#!topic/delayed_job/ZGMUFFppNgs | 2 | # based on https://groups.google.com/forum/#!topic/delayed_job/ZGMUFFppNgs |
3 | class Delayed::Worker::ExceptionNotification < ActionMailer::Base | 3 | class Delayed::Worker::ExceptionNotification < ActionMailer::Base |
4 | - def mail error | 4 | + def mail job, error |
5 | environment = Environment.default | 5 | environment = Environment.default |
6 | 6 | ||
7 | recipients NOOSFERO_CONF['exception_recipients'] | 7 | recipients NOOSFERO_CONF['exception_recipients'] |
8 | from environment.contact_email | 8 | from environment.contact_email |
9 | reply_to environment.contact_email | 9 | reply_to environment.contact_email |
10 | - subject "[#{environment.name}] DelayedJob: #{error.message}" | ||
11 | - body render(:text => error.backtrace.join("\n")) | 10 | + subject "[#{environment.name}] DelayedJob ##{job.id}: #{error.message}" |
11 | + body render(:text => " | ||
12 | +Job: | ||
13 | +#{job.inspect} | ||
14 | + | ||
15 | +Handler: | ||
16 | +#{job.handler} | ||
17 | + | ||
18 | +Backtrace: | ||
19 | +#{error.backtrace.join("\n")} | ||
20 | + ") | ||
12 | end | 21 | end |
13 | end | 22 | end |
14 | 23 | ||
15 | def handle_failed_job_with_notification(job, error) | 24 | def handle_failed_job_with_notification(job, error) |
16 | - Delayed::Worker::ExceptionNotification.deliver_mail error if NOOSFERO_CONF['exception_recipients'].present? | 25 | + Delayed::Worker::ExceptionNotification.deliver_mail job, error if NOOSFERO_CONF['exception_recipients'].present? |
17 | handle_failed_job_without_notification job, error | 26 | handle_failed_job_without_notification job, error |
18 | end | 27 | end |
19 | alias_method_chain :handle_failed_job, :notification | 28 | alias_method_chain :handle_failed_job, :notification |