简体   繁体   English

Sidekiq 没有从 Rails 应用程序中获取工作

[英]Sidekiq not picking up job from Rails app

We are rolling out a new app with Sidekiq and Rails 5. We are leveraging Redis for storing jobs but for some reason both locally and on our dev zone the jobs don't seem to be passing into Redis.我们正在推出带有 Sidekiq 和 Rails 5 的新应用程序。我们正在利用 Redis 来存储作业,但由于某种原因,本地和我们的开发区的作业似乎没有传递到 Redis。

When the code executes on its own as well as via IRB the Notification seems to be properly sent.当代码自行执行以及通过 IRB 执行时,通知似乎已正确发送。

[10] pry(main)> Notifications::WelcomeWorker.perform_async(1)
=> "1a1447c488f173fb09b212f7"

Looking into Redis we have keys for failed and processed (both say 0) but nothing for pending which makes me believe it is not even hitting Redis for some reason.查看 Redis,我们有失败和已处理的键(都说 0),但没有挂起的键,这让我相信它甚至没有因为某种原因击中 Redis。

Our Redis config is setup in config/sidekiq.yml which simply sets concurrency and the PID location.我们的 Redis 配置在 config/sidekiq.yml 中设置,它只设置并发性和 PID 位置。

We have an initializer file as well in initializers/sidekiq.rb我们在 initializers/sidekiq.rb 中也有一个初始化文件

Sidekiq.configure_server do |config|
  config.redis = { url: ENV["SIDEKIQ_REDIS"] , namespace: 'abcbh', network_timeout: 5  }
end
Sidekiq.configure_client do |config|
  config.redis = { url: ENV["SIDEKIQ_REDIS"] , namespace: 'abcbh', network_timeout: 5  }
end

SIDEKIQ_REDIS translates to redis://localhost locally and the relevant URL on dev. SIDEKIQ_REDIS 在本地转换为 redis://localhost 以及在 dev 上的相关 URL。

Everything seems to work fine and yet the jobs do not seem to appear in Redis.一切似乎都运行良好,但作业似乎没有出现在 Redis 中。

Is there something I am missing in my sleep deprivation?在我的睡眠剥夺中我缺少什么吗?

The worker itself is setup in app/workers/notifications/welcome_worker.rb工人本身在 app/workers/notifications/welcome_worker.rb 中设置

In app/workers/notifications/welcome_worker.rb we have the following code though it never gets executed.在 app/workers/notifications/welcome_worker.rb 中,我们有以下代码,尽管它从未被执行。

require 'sendgrid-ruby'
include SendGrid
class Notifications::WelcomeWorker
  include Sidekiq::Worker

  sidekiq_retries_exhausted do |msg, e|
    Sidekiq.logger.warn "Failed #{msg['class']} with #{msg['args']}: #{msg['error_message']}"
  end

  def perform(email_id)
    Sidekiq.logger.info "Beginning Welcome Email For #{email_id}"
    ...
  end
end

After additional Google-fu I found the issue already reported在额外的 Google-fu 之后,我发现问题已经报告了

Sidekiq worker not getting triggered - Please upvote this question and answer if you have come here for the same probelm. Sidekiq 工作人员没有被触发-如果您来这里是为了相同的问题,请对此问题进行投票并回答。 They deserve it more!他们更值得拥有!

TL:DR - rspec-sidekiq gem should be in test only. TL:DR - rspec-sidekiq gem 应该只在测试中。 Apparently this screws with development.显然,这与发展有关。

I will now go bang my head against a wall and wonder why my google-fu failed me for two days straight.我现在将头撞在墙上,想知道为什么我的 google-fu 连续两天都失败了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM