0
我使用任何時間與sidekiq工作的時間表。此外,使用sidekiq-client-cli
gem,這是sidekiq的命令行客戶端,並允許cron作業與sidekiq進行交互。Sidekiq與Whenever
這是我主動的工作文件:
# jobs/clone_record_job.rb
class CloneRecordJob < ActiveJob::Base
queue_as :myapps
def perform(*args)
Core::Block.where(release_date: Date.today - 30.days).each do |block|
new_block = Core::Block.new(block.attributes)
new_block._id = BSON::ObjectId.new
new_block.save
end
end
end
計劃文件:
# config/schedule.rb
job_type :sidekiq, "cd :path && :environment_variable=:environment bundle exec sidekiq-client -q myapps push :task :output"
every 1.minute, :roles => [:app] do
sidekiq "CloneRecordJob"
end
Sidekiq登錄:
2016-08-09T10:13:41.138Z 23668 TID-xvshg WARN: {"class":"CloneRecordJob","queue":"myapps","args":[],"retry":true,"jid":"98cb26a0dd7410a9be0f0200","created_at":1470737621.1380692,"enqueued_at":1470737621.1382036}
2016-08-09T10:13:41.141Z 23668 TID-xvshg WARN: NoMethodError: undefined method `jid=' for #<CloneRecordJob:0x0000000715cc30>
注:
我敢肯定,工作是工作何時從控制中呼叫LER。
# example method
def my_action
CloneRecordJob.perform_now
end
哦,我明白了。我讀過一些wiki,現在我想我需要一個'Sidekiq :: Worker'作爲我的例子,例如:'HardWorker'類 – itx