Peck
Peck

Reputation: 842

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:

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

Upvotes: 2

Views: 2227

Answers (4)

Moozly
Moozly

Reputation: 192

Run it with:

bundle exec ./script/delayed_job -n 5 start

Upvotes: 0

sarfata
sarfata

Reputation: 4675

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.

Upvotes: 1

Peck
Peck

Reputation: 842

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

Upvotes: 0

Seamus Abshere
Seamus Abshere

Reputation: 8526

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

Upvotes: 0

Related Questions