我正在使用Sidekiq 3.1.2 不带Rails :
$ sidekiq -vr sidekiq.rb
sidekiq.rb看起来像这样:
($LOAD_PATH << '.' << 'lib' << 'lib/workers').uniq!
require 'lookup_worker'
lib / workers / lookup_worker.rb看起来像这样:
require 'sidekiq'
class LookupWorker
include Sidekiq::Worker
def perform(*args)
puts "LookupWorker#perform fired with arguments #{args.map(&:inspect).join(', ')}"
end
end
但是当我在irb并尝试
时> LookupWorker.perform_async('asdf')
它给了我这个:
WARN: {"retry"=>true, "queue"=>"default", "class"=>"LookupWorker", "args"=>["asdf"], "jid"=>"8c278868c5f05ec9beb1dbae", "enqueued_at"=>1402457226.9612548}
WARN: uninitialized constant LookupWorker
WARN: [backtrace, none of it from my code]
ERROR: Sidekiq::Processor crashed!
NameError: uninitialized constant LookupWorker
我错过了什么?
答案 0 :(得分:15)
因此...
在LookupWorker
require
中,sidekiq
宝石与第1行脚本sidekiq
之间的混淆。
我的sidekiq.rb
需要重命名为sidekiq_script.rb
(或其他任何内容)。只有陷阱,我必须在运行sidekiq时包含目录:
$ sidekiq -r ./sidekiq_script.rb
不
$ sidekiq -r sidekiq_script.rb
我觉得这有点愚蠢。