我正在尝试使用Resque
1.26.0(和Redis-rb
3.3.1)进行简单的排队工作。该作业似乎没有处理 perform
函数,因为 resque-web
正在处理每个作业并显示 0 次失败。这些作业也正在立即处理。
作业从 Controller 操作中排队
Resque.enqueue(TestJob, url)
工作本身看起来像
class TestJob < ApplicationJob
@queue = :tags_queue
Logger.new("log/resque_worker_QUEUE.log").fatal("thing")
def self.perform(url)
Logger.new("log/resque_worker_QUEUE.log").fatal("other thing")
logger.fatal("more errors please")
myDivideByZeroVar= 1/0
raise "error"
Logger.new("log/resque_worker_QUEUE.log").fatal("other thing")
logger.fatal("more errors please")
end
end
还设置了 rake 任务:
require 'resque/tasks'
task "resque:setup" => :environment
redis-server
正在运行。
工作线程以rake resque:work QUEUE=*
启动。使用详细日志记录不会显示任何有用的信息。
日志文件仅显示第一个 fatal error 字符串“thing”。不会记录 perform
内的任何其他错误。
我在这里做错了什么?
最佳答案
解决了这个问题。需要使用 ActiveJob 调用该作业,而不是使用 Resque.enqueue。 TestJob.perform_later(url)
工作得很好。
关于ruby-on-rails - Rails 5 - Resque 不处理排队作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39443325/