gpt4 book ai didi

ruby-on-rails - delayed_job 的 exception_notification

转载 作者:数据小太阳 更新时间:2023-10-29 07:31:11 25 4
gpt4 key购买 nike

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

最佳答案

我过去曾为延迟的工作佣金任务做过类似的事情:

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

结束

关于ruby-on-rails - delayed_job 的 exception_notification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4104093/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com