delayed_job的exception_notification [英] exception_notification for delayed_job

查看:153
本文介绍了delayed_job的exception_notification的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个exception_notification类似于delayed_job的gem?
最好使用REE-1.8.7和Rails 2.3.10。

Is there a exception_notification-like gem for delayed_job? Preferably that works with REE-1.8.7 and Rails 2.3.10.

推荐答案

我做了一些类似这个在过去的延迟工作耙子任务:

I've done something like this in the past for delayed job rake tasks:

require 'action_mailer'
class ExceptionMailer < ActionMailer::Base
  def setup_mail
    @from = ExceptionNotifier.sender_address
    @sent_on = Time.now
    @content_type = "text/plain"
  end

  def exception_message(subject, message)
    setup_mail
    @subject = subject
    @recipients = ExceptionNotifier.exception_recipients
    @body = message
  end
end

namespace :jobs do
desc "sync the local database with the remote CMS"
task(:sync_cms => :environment) do
  Resort.sync_all!
  result = Delayed::Job.work_off
  unless result[1].zero?
    ExceptionMailer.deliver_exception_message("[SYNC CMS] Error syncing CMS id: #{Delayed::Job.last.id}", Delayed::Job.last.last_error)
  end
end

结束

这篇关于delayed_job的exception_notification的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆