【发布时间】:2016-02-08 22:24:05
【问题描述】:
考虑到延迟工作的工人,
class UserCommentsListWorker
attr_accessor :opts
def initialize opts = {}
@opts = opts
end
def perform
UserCommentsList.new(@opts)
end
def before job
p 'before hook', job
end
def after job
p 'after hook', job
end
def success job
p 'success hook', job
end
def error job, exception
p '4', exception
end
def failure job
p '5', job
end
def enqueue job
p '-1', job
end
end
当我从 rails 控制台运行 Delayed::Job.enqueue UserCommentsListWorker.new(client: client) 时,我可以获得重复的打印语句序列和适当的延迟作业生命周期,甚至可以打印挂钩,包括来自工作人员的作业成功的反馈。
包括通过标准 rails 控制器端点运行 worker 的相同调用;
include OctoHelper
include QueryHelper
include ObjHelper
include StructuralHelper
class CommentsController < ApplicationController
before_filter :authenticate_user!
def index
if params['updateCache'] == 'true'
client = build_octoclient current_user.octo_token
Delayed::Job.enqueue UserCommentsListWorker.new(client: client)
end
end
end
我注意到工作人员将运行并创建延迟的作业,但没有调用任何挂钩并且工作人员从不将作业记录为已完成。
作业 73、75、76 都是通过往返上述端点触发的,而作业 74 是通过 rails 控制台触发的,我的设置有什么问题和/或在此过程中我没有注意到什么?我要强调的是,网络服务器第一次访问上述控制器端点时,作业排队并正常运行,但作业应该正常运行的所有后续实例似乎什么也没做,并且在此过程中没有给我任何反馈。
我还要强调我从未看到失败、错误或排队挂钩运行。
谢谢:)
【问题讨论】: