[英]why doesn't my delayed job work more than once when being triggered from a rails server?
鑒於工作被推遲
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控制器端點(例如;
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控制台觸發的,我的設置有什么問題和/或在此過程中我沒有注意到什么? 我要強調的是,當Web服務器第一次到達上述控制器端點時,該作業會排隊並正常運行,但隨后應正常運行該作業的所有后續實例似乎都什么也不做,並且在此過程中沒有任何反饋。
我還要強調一點,就是我從未見過失敗,錯誤或排隊鈎子運行。
謝謝 :)
解決這個問題的長短是,如果您注意到,我正試圖在延遲的作業通知中存儲client
對象,這會引起問題,因此,不要在作業中存儲復雜的對象,而只是在工作基本數據ID為1
或字符串foo
或booleans true
等。capisce?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.