1. Jan 31st, 2010

    Snipped: send email notification when Resque worker fails

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    
    module Resque
      module Failure
        # Store a copy of the failure in Redis, so we have access from the UI. Also
        # send an email to the developer, so we know something went foul.
        class Notifier < Base
          def save
            # Store in Redis
            super
            # Create notification email
            email = TMail::Mail.new
            email.to = ".. your email here .."
            email.subject = "[Error] #{exception}"
            email.body = <<-EOF
    Queue:    #{queue}
    Worker:   #{worker}
     
    #{payload.inspect}
     
    #{exception}
    #{exception.backtrace.join("\n")}
            EOF
            Mailer.deliver email
          rescue
          end
        end
      end
    end
     
    Resque::Failure.backend = Resque::Failure::Notifier if ENV['RAILS_ENV'] == "production"
    1. Jun 29th, 2010

      nahum

      Sweet, thanks for this.

    2. May 10th, 2011

      JIRA: Nucleus Kader

      [KAD-186] Worker tasks need a mechanism for reporting failed tasks…

      null Currently, when a worker task fails the job shows up as a failure in the Resque server. It would be nice to have failure notices sent to Kader admins for investigation. It may be possible to extend the existing Resque Failure module to email or n….

    Your comment, here ⇓