Delayed_job and paperclip - Images are not processed but no errors?

I am having big problems trying to get delayed_job to work with Amazon S3 and Paperclip. There are several posts on how to do this, but for some reason it just doesn't work for me. I removed a couple of things as others do - initially I had persistence (validations => false) in regenerate_styles, but this seemed to cause an infinite loop (due to persistence after catch) and not (since urls are saved. only images are not loaded). Here's the relevant code from my model file, submission.rb:

class Submission < ActiveRecord::Base
  has_attached_file :photo ...

  ...

  before_photo_post_process do |submission|
    if photo_changed?
      false
    end
  end

  after_save do |submission|
    if submission.photo_changed?
      Delayed::Job.enqueue ImageJob.new(submission.id)
    end
  end

  def regenerate_styles!
    puts "Processing photo"
    self.photo.reprocess!
  end

  def photo_changed?
    self.photo_file_size_changed? ||
    self.photo_file_name_changed? ||
    self.photo_content_type_changed? ||
    self.photo_updated_at_changed?
  end
end

      

And my little ImageJob class, which is at the bottom of the submission.rb file:

class ImageJob < Struct.new(:submission_id)
  def perform
    Submission.find(self.submission_id).regenerate_styles!
  end
end

      

As far as I can tell, the job itself is being generated correctly (since I can pull it from the database using a query).

The problem arises when:

$ rake jobs:work
WARNING: Nokogiri was built against LibXML version 2.7.8, but has dynamically loaded 2.7.3
[Worker(host:Jarrod-Robins-MacBook.local pid:21738)] New Relic Ruby Agent Monitoring DJ worker host:MacBook.local pid:21738
[Worker(host:MacBook.local pid:21738)] Starting job worker
Processing photo
[Worker(host:MacBook.local pid:21738)] ImageJob completed after 9.5223
[Worker(host:MacBook.local pid:21738)] 1 jobs processed at 0.1045 j/s, 0 failed ...

      

The rake task then gets stuck and never exits, and the images themselves don't seem to have been reworked.

Any ideas?

EDIT: one more point; the same thing happens on the hero, not just locally.

+3


source to share


1 answer


The job specified is to capture the stack trace for all failed jobs. It is stored in a column of the last_error

table delayed_jobs

. Using the database also shows what's going on.

If you have to use a collection of ideas with ActiveRecord as the backend , you can request the model as usual. To get an array of all stack traces, for example

Delayed::Job.where('failed_at IS NOT NULL').map(&:last_error)

      



By default, failed jobs are deleted after 25 failed attempts. Maybe there are no more jobs. Prevent uninstallation for debugging purposes by setting

Delayed::Worker.destroy_failed_jobs = false

      

in config/initializers/delayed_job_config.rb

0


source







All Articles