在生产模式下使用acts_as_ferret的DelayedJob [英] DelayedJob with acts_as_ferret in production mode

查看:98
本文介绍了在生产模式下使用acts_as_ferret的DelayedJob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过DelayedJob运行任务时出现以下错误:

I get the following error when I run my task via 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'
...

从该错误中可以明显看出,delay_job无法找到ferret_server.但是,当我在生产模式下从控制台运行此SAME任务时,它工作正常.关于如何确保delay_job具有以下任何想法:

From the error its obvious that delayed_job could not find the ferret_server. However, when I run this SAME task from console in production mode, it works fine. Any ideas how I can ensure that delayed_job has:

  1. 真正加载了生产环境.为了确保这一点,我在脚本/delayed_job中设置了RAILS ['ENV]] ='production'. (我想这应该很好)

  1. really loaded the production environment. I set RAILS['ENV]] = 'production' in the script/delayed_job to ensure this. (I guess this should be good)

通过模型配置了雪貂吗?

got ferret configured via models?

推荐答案

这也发生在我身上.您需要在运行延迟的作业期间禁止雪貂索引.

This happened to me too. You need to disable ferret from indexing during the running of the delayed job.

在您的工作程序定义中(类似RAILS_ROOT/lib/worker.rb),并给一个名为Post的模型,您应该包括这样的一行:

In your worker definition (something like RAILS_ROOT/lib/worker.rb), and given a model called Post, you should include a line like this:

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

这篇关于在生产模式下使用acts_as_ferret的DelayedJob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆