2015-06-05 3 views
-1

У меня есть классифицированная модель, где я использую обратный вызов after_create для проверки ключевых слов пользователя и отправки уведомлений по электронной почте.Ошибки Sucker_punch или неправильно выполняемые фоновые задания

Это электронное письмо отправлено фоновой работой с использованием ActiveJobs и Sucker_punch в качестве фона драйвера.

Я вижу в журналах 3 задания в очередь:

[ActiveJob] Enqueued ActionMailer::DeliveryJob (Job ID: 8843b126-18fe-4cc1-b2f3-41141a199bcb) to SuckerPunch(mailers) with arguments: "NotificationMailer", "keyword_found", "deliver_now", gid://clasificados/Classified/233, gid://clasificados/User/1 

[ActiveJob] Enqueued ActionMailer::DeliveryJob (Job ID: 591ce6eb-34d1-4381-93ea-4b708171996f) to SuckerPunch(mailers) with arguments: "NotificationMailer", "keyword_found", "deliver_now", gid://clasificados/Classified/234, gid://clasificados/User/1 

[ActiveJob] Enqueued ActionMailer::DeliveryJob (Job ID: 3b1de0ea-f48d-41f2-be5a-8f5b2369b8ea) to SuckerPunch(mailers) with arguments: "NotificationMailer", "keyword_found", "deliver_now", gid://clasificados/Classified/235, gid://clasificados/User/1 

, но я получил только писем ...

я вижу в журналах ошибок, как:

Terminating 6 actors... 
Terminating task: type=:finalizer, meta={:method_name=>:__shutdown__}, status=:receiving 
    Celluloid::TaskFiber backtrace unavailable. Please try `Celluloid.task_class = Celluloid::TaskThread` if you need backtraces here.` 

Terminating task: type=:call, meta={:method_name=>:perform}, status=:callwait 
    Celluloid::TaskFiber backtrace unavailable. Please try `Celluloid.task_class = Celluloid::TaskThread` if you need backtraces here. 
Celluloid::PoolManager: async call `perform` aborted! 
Celluloid::Task::TerminatedError: task was terminated 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:34:in `terminate' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:345:in `each' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:345:in `cleanup' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:329:in `shutdown' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:164:in `run' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:130:in `block in start' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/thread_handle.rb:13:in `block in initialize' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor_system.rb:32:in `block in get_thread' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/internal_pool.rb:130:in `call' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/internal_pool.rb:130:in `block in create' 
Terminating task: type=:call, meta={:method_name=>:perform}, status=:callwait 
    Celluloid::TaskFiber backtrace unavailable. Please try `Celluloid.task_class = Celluloid::TaskThread` if you need backtraces here. 
Celluloid::PoolManager: async call `perform` aborted! 
Celluloid::Task::TerminatedError: task was terminated 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:34:in `terminate' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:345:in `each' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:345:in `cleanup' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:329:in `shutdown' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:164:in `run' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:130:in `block in start' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/thread_handle.rb:13:in `block in initialize' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor_system.rb:32:in `block in get_thread' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/internal_pool.rb:130:in `call' 
    /home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/internal_pool.rb:130:in `block in create' 
Terminating task: type=:finalizer, meta={:method_name=>:__shutdown__}, status=:receiving 
    Celluloid::TaskFiber backtrace unavailable. Please try `Celluloid.task_class = Celluloid::TaskThread` if you need backtraces here. 

Модель:

class Classified < ActiveRecord::Base 

    after_create :find_matched_keywords 

    def find_matched_keywords 
    User.all.each do |u| 
     u.profile.keywords.scan(/[a-zA-Z\d]+/) do |k| 
     if self[:content].downcase.include?(k) 
      SendEmailJob.new.async.perform(self, u) 
      break 
     end 
     end 
    end 
    end 

end 

Работа:

class SendEmailJob < ActiveJob::Base 
    include SuckerPunch::Job 
    queue_as :default 

    def perform(classified, user) 
    NotificationMailer.keyword_found(classified, user).deliver_later 
    end 
end 

любая идея, что могло случиться?

заранее спасибо: D

ответ

1

хорошо, я изменил к sidekiq ... проблема решена.

Смежные вопросы