简体   繁体   English

Heroku上未处理delay_job队列

[英]delayed_job queue not being processed on Heroku

I'm running a Rails 3 app with delayed_job. 我正在运行带有delay_job的Rails 3应用程序。 The issue I've come across is that though the app is correctly adding jobs to the queue, they are never being processed. 我遇到的问题是,尽管应用程序正确地将作业添加到队列中,但从未对其进行处理。

My Class 我的课

class User < ActiveRecord::Base
  after_create :send_welcome_email

  private

    def send_welcome_email
      UserMailer.delay.welcome_email(self)
    end
end

Inspecting things through the Rails console I can see that there are jobs in the queue. 通过Rails控制台检查事物,我可以看到队列中有作业。 I can also see that there have been 0 attempts to perform the jobs. 我还可以看到有0次尝试执行作业。 Spinning up a Heroku worker doesn't cause the jobs to be processed. 提升Heroku工作人员不会导致作业得到处理。

Any ideas? 有任何想法吗?

Thanks! 谢谢!

Edit: Trying to clear the jobs queue as suggested below I ran rake jobs:clear and received the following error 编辑:尝试按照下面的建议清除作业队列,我运行rake jobs:clear并收到以下错误

rake aborted!
uninitialized constant Rake::DSL
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.0/lib/rake/tasklib.rb:8:in `<class:TaskLib>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.0/lib/rake/tasklib.rb:6:in `<module:Rake>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.0/lib/rake/tasklib.rb:3:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.0/lib/rake/rdoctask.rb:20:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/tasks/documentation.rake:1:in `<top (requ
ired)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/tasks.rb:15:in `block in <top (required)>
'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/tasks.rb:6:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/tasks.rb:6:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:214:in `initialize_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:139:in `load_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
/app/Rakefile:7:in `<top (required)>'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `load'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1991:in `run'
/usr/ruby1.9.2/bin/rake:31:in `<main>'

In the end, the problem turned out to be a bug in Rake 0.9.0. 最后,问题出在Rake 0.9.0中。 As Rails depends on Rake, running bundle install after this release of Rake broke my delayed jobs. 由于Rails依赖Rake,因此在此版本的Rake之后运行bundle install破坏了我的延迟工作。

The fix is to add gem 'rake', '0.8.7' to your gemfile. 解决方法是将gem 'rake', '0.8.7'到您的gemfile中。

More details can be found below... 可以在下面找到更多详细信息...

DHH's tweet: http://twitter.com/dhh/status/71966528744071169 DHH的推文: http : //twitter.com/dhh/status/71966528744071169

Discussion in rails_admin's issue tracker: https://github.com/sferik/rails_admin/issues/428 在rails_admin的问题跟踪器中进行的讨论: https : //github.com/sferik/rails_admin/issues/428

Two options for you: 您有两个选择:

These two gems watch delayed_jobs queue and automatically 'hires' background workers to process the thread: 这两个gem监视delay_jobs队列并自动“雇用”后台工作人员来处理线程:

Good luck 祝好运

Are you running the delayed_job daemon in the same environment in which the application is running? 您是否在与应用程序运行相同的环境中运行delay_job守护程序?

Try working the jobs manually using: 尝试使用以下方法手动处理作业:
rake RAILS_ENV=development jobs:work

If you are running your app in production mode then you need to start delayed_job daemon as: 如果您以生产模式运行应用程序,则需要以以下方式启动delay_job守护程序:
RAILS_ENV=production script/delayed_job start

This is kinda a long shot but make sure you are using the same Ruby version on Heroku as you are on your local machine. 这有点长,但是请确保在Heroku上使用与本地计算机上相同的Ruby版本。 I had a problem with delayed jobs on Heroku before because of this. 因此,我之前在Heroku上推迟工作遇到了问题。

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

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