gpt4 book ai didi

ruby-on-rails - 在 Rails 4 中使用延迟作业配置异常通知

转载 作者:行者123 更新时间:2023-12-04 04:41:49 24 4
gpt4 key购买 nike

当延迟作业失败时,我无法让异常通知 gem 通知我。我可以让作业失败,但不会发出通知。有其他人想出这个吗?

我正在使用:

delayed_job_active_record (4.0.0)
exception_notification (4.0.0)

并在我的初始化程序/delayed_jobs_config 中有以下内容:
# Chain delayed job's handle_failed_job method to do exception notification
Delayed::Worker.class_eval do
def handle_failed_job_with_notification(job, error)
handle_failed_job_without_notification(job, error)
# only actually send mail in production
if Rails.env.production?
# rescue if ExceptionNotifier fails for some reason
begin
ExceptionNotifier::Notifier.background_exception_notification(error)
rescue Exception => e
Rails.logger.error "ExceptionNotifier failed: #{e.class.name}: #{e.message}"
e.backtrace.each do |f|
Rails.logger.error " #{f}"
end
Rails.logger.flush
end
end
end
alias_method_chain :handle_failed_job, :notification
end

最佳答案

自异常通知 4.0 there's a new way to handle manual notify .尝试改变

ExceptionNotifier::Notifier.background_exception_notification(error)

对于
ExceptionNotifier.notify_exception(error)

关于ruby-on-rails - 在 Rails 4 中使用延迟作业配置异常通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18777746/

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