resque-status 参数错误

发布于 2024-11-24 08:29:36 字数 1484 浏览 0 评论 0原文

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

需要“sinatra/base”
需要“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

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

SleepJob({"length"=>100})

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

The task failed because of an error: wrong number of arguments (0 for 1)

有人知道问题是什么吗?

谢谢。

I have a very basic Sinatra app to test 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 << '  <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

In the statuses tab I can see that the job has 1 argument:

SleepJob({"length"=>100})

But the status is set to failed with the message:

The task failed because of an error: wrong number of arguments (0 for 1)

Anyone knows what the issue is?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文