开发者

Undefined Method Error when creating delayed_job workers with script/delay_job

Having a bit of a problem running multiple workers.

When creating workers with rake jobs:work jobs run without and problem, even when invoking it multiple times, but when creating workers with ruby script/delayed_job -n 5 start all jobs fail with undefined method on Syck::DomainType.

I've searched quite a bit, but can't seem to find the solution for this. I am running DelayedJob on the Mongoid backend. Gem versions:

  • rake 0.9.2
  • rails 3.0.6
  • delayedjob 2.1.4
  • delayedjob_mongoid 1.0.2

Has anyone experienced a similar error/have a solution? Or short of that some information on why/how workers 开发者_Go百科are being created differently depending on which way they are invoked?


I had the exact same problem. I could reproduce it by loading the job in the console and trying to unserialize it:

$ rails console production
> j = Delayed::Job.last
> YAML.load(j.handler)

On my production environment, I got a Syck::DomainType object whereas in development it just unserialized my object (the data stored in db is the same in both case).

Long story short, I realized that I had ruby 1.9.1 instead of 1.9.2 on my server. Switching to an rvm managed environment with ruby-1.9.2p290 solved the problem for me.


Perhaps ruby script/delayed_job -n 5 start all doesn't invoke Bundler.setup and that's why it's different from other ways of launching workers? (Just a guess)

You may be able to fix the Syck::DomainType error by putting this at the top of config/application.rb

require 'yaml'
YAML::ENGINE.yamler = 'syck'
# [...]
require File.expand_path('../boot', __FILE__)

Thanks to this answer: rails error, couldn't parse YAML


It looks like the problem was derived from bundler >= 1.0.10 loading up psych and overwriting some of sycks functionality if libyaml is present. I was able to remove the libyaml install from my system, something that I know won't be possible for everyone. Tough to track down, hopefully this post will help someone else


Run it with:

bundle exec ./script/delayed_job -n 5 start
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜