[英]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
.当创建具有
rake jobs:work
作业运行没有问题,即使多次调用它,但是当使用ruby script/delayed_job -n 5 start all
jobs 在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.
我在 Mongoid 后端运行 DelayedJob。 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?
或者缺少一些关于为什么/如何根据调用方式不同创建工作人员的信息?
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).在我的生产环境中,我得到了一个 Syck::DomainType object 而在开发中它只是反序列化了我的 object(存储在 db 中的数据在两种情况下都是相同的)。
Long story short, I realized that I had ruby 1.9.1 instead of 1.9.2 on my server.长话短说,我意识到我的服务器上有 ruby 1.9.1 而不是 1.9.2。 Switching to an rvm managed environment with ruby-1.9.2p290 solved the problem for me.
使用 ruby-1.9.2p290 切换到 rvm 托管环境为我解决了这个问题。
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?也许
ruby script/delayed_job -n 5 start all
不会调用Bundler.setup
,这就是为什么它不同于其他启动工作人员的方式? (Just a guess) (只是猜测)
You may be able to fix the Syck::DomainType
error by putting this at the top of config/application.rb
您可以通过将其放在
config/application.rb
的顶部来修复Syck::DomainType
错误
require 'yaml'
YAML::ENGINE.yamler = 'syck'
# [...]
require File.expand_path('../boot', __FILE__)
Thanks to this answer:rails error, couldn't parse YAML感谢这个答案:rails error, could'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.如果存在 libyaml,则问题似乎源自 bundler >= 1.0.10 加载 psych 并覆盖某些 sycks 功能。 I was able to remove the libyaml install from my system, something that I know won't be possible for everyone.
我能够从我的系统中删除 libyaml 安装,我知道这对每个人来说都是不可能的。 Tough to track down, hopefully this post will help someone else
很难追查,希望这篇文章对其他人有帮助
Run it with:运行它:
bundle exec ./script/delayed_job -n 5 start
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.