我不知道我在这里做了什么,但我尝试让Rails中的一个控制器将作业排队到Resque上,然后一个工作进程连接并执行繁重的工作(例如比较、数据库条目)。然而,由于没有设置Resque的明确说明,这些任务甚至没有运行。
以下是复制和粘贴的内容: 也可以在Gist格式中使用! 这是来自Hoptoad的异常行:
这是“worker”文件的内容:
这是“web_controller”文件的内容:
非常感谢您的时间,如果您需要更多信息,请随时与我联系。
卢克·卡彭特
以下是复制和粘贴的内容: 也可以在Gist格式中使用! 这是来自Hoptoad的异常行:
NoMethodError: undefined method 'perform' for Violateq:Module
这是“worker”文件的内容:
module Violateq
@queue = :violateq
def perform(nick, rulenumber)
# Working for the weekend!!!
puts "I got a nick of #{nick} and they broke #{rulenumber}"
@violation = Violation.new(nick, rulenumber)
puts "If you got this far, your OK"
log_in(:worker_log, {:action => "Violate d=perfom", :nick => nick, :rulenumber => rulenumber, :status => "success"})
#rescue => ex
# notify_hoptoad(ex)
# log_in(:worker_log, {:action => "Violate d=perfom", :nick => nick, :rulenumber => rulenumber, :status => "failure"})
end
end
这是“web_controller”文件的内容:
class IncomingController < ApplicationController
require 'mail'
skip_before_filter :verify_authenticity_token
def create
message = Mail.new(params[:message])
# Push the message into the queue
Resque.enqueue(Violateq, message.from.to_s, message.subject.to_s)
log_in(:endpoint_log, {:action => "IncomingController d=create", :subject => message.subject, :message => message.body.decoded})
render :text => 'success', :status => 200 # a status of 404 would reject the mail
rescue => ex
notify_hoptoad(ex)
render :text => 'failure', :status => 500
end
end
非常感谢您的时间,如果您需要更多信息,请随时与我联系。
卢克·卡彭特