我有将请求发送到服务器并检查是否存在文件的工作程序。现在,worker在指定的时间运行:
CheckFileWorker.perform_in(@target_file.check_start_date, @target_file.url)
我正在使用Sidetiq安排重复的后台作业(https://github.com/tobiassvn/sidetiq)。
基本上,您应该执行以下操作:
class LicenseCheckerWorker
include Sidekiq::Worker
include Sidetiq::Schedulable
recurrence { hourly }
def perform
#your logic here
end
end
当然,您应该更改重复计划以反映您的偏好。
编辑:另一种方法是在#perform逻辑的末尾安排另一次运行,延迟2秒。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句