0

我整天都在用头撞这个。我正在尝试使用以下设置 Resqueresque.rake

require 'resque/tasks'
require 'resque_scheduler/tasks'

task "resque:setup" => :environment do
  Resque.after_fork do |job|
    ActiveRecord::Base.establish_connection
  end
  ENV['QUEUE'] ||= '*'
end

当我运行时rake resque:work --trace,出现以下错误:

The Gemfile's dependencies are satisfied
** Invoke resque:work (first_time)
** Invoke resque:preload (first_time)
** Invoke resque:setup (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute resque:setup
** Execute resque:preload
Connecting to database specified by database.yml
** Invoke resque:setup 
** Execute resque:work
rake aborted!
undefined method `get' for #<Hash:0x000000021a0b88>
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/redis-namespace-1.2.1/lib/redis/namespace.rb:257:in `method_missing'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/resque-1.23.0/lib/resque/worker.rb:517:in `job'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/resque-1.23.0/lib/resque/worker.rb:450:in `unregister_worker'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/resque-1.23.0/lib/resque/worker.rb:169:in `rescue in work'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/resque-1.23.0/lib/resque/worker.rb:129:in `work'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/resque-1.23.0/lib/resque/tasks.rb:36:in `block (2 levels) in <top (required)>'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/share/eugene/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/bin/rake:23:in `load'
/share/eugene/.rvm/gems/ruby-1.9.3-p327/bin/rake:23:in `<main>'
Tasks: TOP => resque:work

我的 Gemfile 有以下相关的 Gems:

gem 'resque'
gem 'resque-scheduler'

我也有以下初始化程序,但我认为此时它不相关:

require 'resque'
require 'resque_scheduler'

Resque.redis           = YAML.load_file('config/resque.yml')
Resque.schedule        = YAML.load_file('config/resque_schedule.yml')

有人有什么想法吗?

4

1 回答 1

1

我很笨。

Resque.redis = YAML.load_file('config/resque.yml')

需要是

Resque.redis = Redis.new YAML.load_file('config/resque.yml')
于 2013-03-04T23:00:19.653 回答