resque-status参数错误

时间:2011-07-15 17:23:27

标签: ruby resque

我有一个非常基本的Sinatra应用程序来测试resque-status

require 'sinatra/base'
require 'resque' require 'resque/job_with_status'

class SleepJob < Resque::JobWithStatus

  def perform
    total = options['length'].to_i || 1000
    num = 0 
    while num < total
      at(num, total, "At #{num} of #{total}")
      sleep(1)
      num += 1
    end 
    completed
  end 

end

class App < Sinatra::Base
  get '/' do
    info = Resque.info
    out = "<html><head><title>Resque Demo</title></head><body>"
    out << "<p>"
    out << "There are #{info[:pending]} pending and "
    out << "#{info[:processed]} processed jobs across #{info[:queues]} queues."
    out << "</p>"
    out << "<form action='/sleep' method='POST''>"
    out << '<input type="submit" value="Sleep Job"/>'
    out << '&nbsp;&nbsp;<a href="/resque/">View Resque</a>'
    out << '</form>'
    out << "</body></html>"
    out 
  end 

  post '/sleep' do
    job_id = SleepJob.create(:length => 100)
    redirect "/resque/"
  end 
end

class SleepJob < Resque::JobWithStatus def perform total = options['length'].to_i || 1000 num = 0 while num < total at(num, total, "At #{num} of #{total}") sleep(1) num += 1 end completed end end class App < Sinatra::Base get '/' do info = Resque.info out = "<html><head><title>Resque Demo</title></head><body>" out << "<p>" out << "There are #{info[:pending]} pending and " out << "#{info[:processed]} processed jobs across #{info[:queues]} queues." out << "</p>" out << "<form action='/sleep' method='POST''>" out << '<input type="submit" value="Sleep Job"/>' out << '&nbsp;&nbsp;<a href="/resque/">View Resque</a>' out << '</form>' out << "</body></html>" out end post '/sleep' do job_id = SleepJob.create(:length => 100) redirect "/resque/" end end

在状态选项卡中,我可以看到该作业有一个参数:

但状态设置为失败,显示消息:

SleepJob({"length"=>100})

任何人都知道这是什么问题?

感谢。

0 个答案:

没有答案