views:

186

answers:

1

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'
...

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. really loaded the production environment. I set RAILS['ENV]] = 'production' in the script/delayed_job to ensure this. (I guess this should be good)

  2. got ferret configured via models?

A: 

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:

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