Rails / Sidekiq在无法识别的模块中工作失败

时间:2018-09-25 19:40:00

标签: ruby-on-rails sidekiq

从下面的堆栈跟踪中可以看到,Reminders::FindStaleJobsJob由于未初始化的常量Reminders引起了问题。我没有得到的是,我在任何地方都没有打电话给Reminders::FindStaleJobsJob;我叫Recaps::FindStaleJobsJob

我已经清除了Sidekiq队列,但仍然反复收到此错误。

2018-09-25T17:45:14.539Z 12784 TID-oxxicof3s INFO: Running in ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin17]
2018-09-25T17:45:14.539Z 12784 TID-oxxicof3s INFO: See LICENSE and the LGPL-3.0 for licensing details.
2018-09-25T17:45:14.539Z 12784 TID-oxxicof3s INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org
2018-09-25T17:45:14.541Z 12784 TID-oxxicof3s INFO: Starting processing, hit Ctrl-C to stop
2018-09-25T18:00:05.107Z 12784 TID-oxxi975os Recaps::FindStaleJobsJob JID-ec113586e3f8fe72eb3ca479 INFO: start
2018-09-25T18:00:05.135Z 12784 TID-oxxim1crg ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper JID-4bc5f87567ca3f019b2015e4 INFO: start
2018-09-25T18:00:05.136Z 12784 TID-oxxi970ss Recaps::FindStaleJobsJob JID-3125783fd5da7604b95bb813 INFO: start
2018-09-25T18:00:05.155Z 12784 TID-oxxim1crg ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper JID-4bc5f87567ca3f019b2015e4 INFO: fail: 0.02 sec
2018-09-25T18:00:05.155Z 12784 TID-oxxim1crg WARN: {"context":"Job raised exception","job":{"class":"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper","queue":"default","description":"","args":[{"job_class":"Reminders::FindStaleJobsJob","job_id":"d6161fcf-2abd-4e2b-8946-73668a78282f","queue_name":"default","arguments":[]}],"retry":true,"jid":"4bc5f87567ca3f019b2015e4","created_at":1537898405.1336598,"enqueued_at":1537898405.133705},"jobstr":"{\"class\":\"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper\",\"queue\":\"default\",\"description\":\"\",\"args\":[{\"job_class\":\"Reminders::FindStaleJobsJob\",\"job_id\":\"d6161fcf-2abd-4e2b-8946-73668a78282f\",\"queue_name\":\"default\",\"arguments\":[]}],\"retry\":true,\"jid\":\"4bc5f87567ca3f019b2015e4\",\"created_at\":1537898405.1336598,\"enqueued_at\":1537898405.133705}"}
2018-09-25T18:00:05.155Z 12784 TID-oxxim1crg WARN: NameError: uninitialized constant Reminders

我的Sidekiq cron初始化程序:

#/config/initializers/sidekiq_cron_scheduler.rb
jobs_hash = {
  'recap' => {
    'class' => 'Recaps::FindStaleJobsJob',
    'cron' => '0, 15, 30, 45 * * * *',
    'active_job' => true
  }
}

Sidekiq::Cron::Job.load_from_hash jobs_hash

我在做些愚蠢而显而易见的事情吗?

1 个答案:

答案 0 :(得分:0)

某处挂了东西。我从sidekiq-cron初始化程序中删除了Recaps模块,并使其失败了。然后,我重新引入了模块名称,并在其中散布了一些redis-cli flushall命令,一切似乎都工作正常。