简体   繁体   English

在生产模式下使用acts_as_ferret的DelayedJob

[英]DelayedJob with acts_as_ferret in production mode

I get the following error when I run my task via DelayedJob: 通过DelayedJob运行任务时出现以下错误:

closed stream
/usr/lib/ruby/1.8/drb/drb.rb:961:in `select'
/usr/lib/ruby/1.8/drb/drb.rb:961:in `alive?'
/usr/lib/ruby/1.8/drb/drb.rb:1211:in `alive?'
/usr/lib/ruby/1.8/drb/drb.rb:1168:in `open'
/usr/lib/ruby/1.8/drb/drb.rb:1166:in `each'
/usr/lib/ruby/1.8/drb/drb.rb:1166:in `open'
/usr/lib/ruby/1.8/drb/drb.rb:1163:in `synchronize'
/usr/lib/ruby/1.8/drb/drb.rb:1163:in `open'
/usr/lib/ruby/1.8/drb/drb.rb:1092:in `method_missing'
/usr/lib/ruby/1.8/drb/drb.rb:1110:in `with_friend'
/usr/lib/ruby/1.8/drb/drb.rb:1091:in `method_missing'
/usr/lib/ruby/gems/1.8/gems/acts_as_ferret-0.4.3/lib/remote_index.rb:31:in `<<'
/usr/lib/ruby/gems/1.8/gems/acts_as_ferret-0.4.3/lib/instance_methods.rb:90:in `ferret_update'
...

From the error its obvious that delayed_job could not find the ferret_server. 从错误中可以明显看出,delay_job无法找到ferret_server。 However, when I run this SAME task from console in production mode, it works fine. 但是,当我在生产模式下从控制台运行此SAME任务时,它工作正常。 Any ideas how I can ensure that delayed_job has: 我如何确保delay_job的任何想法:

  1. really loaded the production environment. 真正加载了生产环境。 I set RAILS['ENV]] = 'production' in the script/delayed_job to ensure this. 我在脚本/ delayed_job中设置了RAILS ['ENV]] ='production'以确保这一点。 (I guess this should be good) (我想这应该很好)

  2. got ferret configured via models? 通过模型配置了雪貂吗?

This happened to me too. 这也发生在我身上。 You need to disable ferret from indexing during the running of the delayed job. 您需要在运行延迟的作业期间禁止雪貂索引。

In your worker definition (something like RAILS_ROOT/lib/worker.rb), and given a model called Post, you should include a line like this: 在您的工作程序定义(类似于RAILS_ROOT / lib / worker.rb之类)中,并给一个名为Post的模型,您应该包括这样的一行:

class Worker < Struct.new(:stuff)
  def perform
    Post.disable_ferret
    <do some stuff>
    .
    .
    .
  end
end

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

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