Sha256: cb8464a21c688be677f4adf2f7e0a0ce2287985241283d5a37393f837abfb374
Contents?: true
Size: 803 Bytes
Versions: 3
Compression:
Stored size: 803 Bytes
Contents
module Sidejobs class Processor def process original_logger = ActiveJob::Base.logger ActiveJob::Base.logger = Sidejobs.logger Sidejobs.queue.fetch.each do |job| Sidejobs.logger.info "Processing ##{job.id} attempt #{job.attempts} of #{job.data['job_class']}" job.update status: 'processing', processed_at: Time.now, attempts: job.attempts+1 begin ActiveJob::Base.execute job.data job.update status: 'complete', completed_at: Time.now Sidejobs.logger.info 'Done' rescue => exception job.update status: 'failing', failed_at: Time.now, error: exception.message Sidejobs.logger.info "Error: #{exception.message}" end end ActiveJob::Base.logger = original_logger end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sidejobs-4.0.0.1 | lib/sidejobs/processor.rb |
sidejobs-4.0.0.0 | lib/sidejobs/processor.rb |
sidejobs-0.0.1 | lib/sidejobs/processor.rb |