jeudi 29 octobre 2015

Carrierwave_backgrounder and delayed_job not working on Heroku: No such file or directory

I am using the Carrierwave_backgrounder, delayed_job and daemons gem to handle uploading multiple images on my application without stealing bandwidth from other users immediately. The worker will run with no issues on my local development server. After pushing to my Heroku staging environment I receive these errors while attempting to complete the jobs.

  Delayed::Backend::ActiveRecord::Job Load (2.5ms)  UPDATE "delayed_jobs" SET locked_at = '2015-10-28 23:46:15.299335', locked_by = 'host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3' WHERE id IN (SELECT  "delayed_jobs"."id" FROM "delayed_jobs" WHERE ((run_at <= '2015-10-28 23:46:15.298692' AND (locked_at IS NULL OR locked_at < '2015-10-28 19:46:15.298734') OR locked_by = 'host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3') AND failed_at IS NULL)  ORDER BY priority ASC, run_at ASC LIMIT 1 FOR UPDATE) RETURNING *
[Worker(host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3)] Job CarrierWave::Workers::StoreAsset (id=20) RUNNING
2015-10-28T23:46:15+0000: [Worker(host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3)] Job CarrierWave::Workers::StoreAsset (id=20) RUNNING
  VehicleImage Load (0.7ms)  SELECT  "vehicle_images".* FROM "vehicle_images" WHERE "vehicle_images"."id" = $1 LIMIT 1  [["id", 91]]
[Worker(host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3)] Job CarrierWave::Workers::StoreAsset (id=20) FAILED (4 prior attempts) with Errno::ENOENT: No such file or directory - /app/public/uploads/tmp/1446075582-3-5608/Cancer_show_031.JPG
2015-10-28T23:46:15+0000: [Worker(host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3)] Job CarrierWave::Workers::StoreAsset (id=20) FAILED (4 prior attempts) with Errno::ENOENT: No such file or directory - /app/public/uploads/tmp/1446075582-3-5608/Cancer_show_031.JPG
   (0.6ms)  BEGIN
  SQL (0.8ms)  UPDATE "delayed_jobs" SET "attempts" = $1, "run_at" = $2, "locked_at" = $3, "locked_by" = $4, "updated_at" = $5 WHERE "delayed_jobs"."id" = $6  [["attempts", 5], ["run_at", "2015-10-28 23:56:45.308678"], ["locked_at", nil], ["locked_by", nil], ["updated_at", "2015-10-28 23:46:15.310442"], ["id", 20]]
   (1.4ms)  COMMIT
  Delayed::Backend::ActiveRecord::Job Load (2.0ms)  UPDATE "delayed_jobs" SET locked_at = '2015-10-28 23:46:15.318187', locked_by = 'host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3' WHERE id IN (SELECT  "delayed_jobs"."id" FROM "delayed_jobs" WHERE ((run_at <= '2015-10-28 23:46:15.317874' AND (locked_at IS NULL OR locked_at < '2015-10-28 19:46:15.317891') OR locked_by = 'host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3') AND failed_at IS NULL)  ORDER BY priority ASC, run_at ASC LIMIT 1 FOR UPDATE) RETURNING *
[Worker(host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3)] Job CarrierWave::Workers::StoreAsset (id=21) RUNNING
2015-10-28T23:46:15+0000: [Worker(host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3)] Job CarrierWave::Workers::StoreAsset (id=21) RUNNING
  VehicleImage Load (0.7ms)  SELECT  "vehicle_images".* FROM "vehicle_images" WHERE "vehicle_images"."id" = $1 LIMIT 1  [["id", 92]]
[Worker(host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3)] Job CarrierWave::Workers::StoreAsset (id=21) FAILED (4 prior attempts) with Errno::ENOENT: No such file or directory - /app/public/uploads/tmp/1446075582-3-0693/Cancer_show_033.JPG
2015-10-28T23:46:15+0000: [Worker(host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3)] Job CarrierWave::Workers::StoreAsset (id=21) FAILED (4 prior attempts) with Errno::ENOENT: No such file or directory - /app/public/uploads/tmp/1446075582-3-0693/Cancer_show_033.JPG
   (0.6ms)  BEGIN
  SQL (1.2ms)  UPDATE "delayed_jobs" SET "attempts" = $1, "run_at" = $2, "locked_at" = $3, "locked_by" = $4, "updated_at" = $5 WHERE "delayed_jobs"."id" = $6  [["attempts", 5], ["run_at", "2015-10-28 23:56:45.322803"], ["locked_at", nil], ["locked_by", nil], ["updated_at", "2015-10-28 23:46:15.324371"], ["id", 21]]
   (1.5ms)  COMMIT
  Delayed::Backend::ActiveRecord::Job Load (2.2ms)  UPDATE "delayed_jobs" SET locked_at = '2015-10-28 23:46:15.329835', locked_by = 'host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3' WHERE id IN (SELECT  "delayed_jobs"."id" FROM "delayed_jobs" WHERE ((run_at <= '2015-10-28 23:46:15.329385' AND (locked_at IS NULL OR locked_at < '2015-10-28 19:46:15.329409') OR locked_by = 'host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3') AND failed_at IS NULL)  ORDER BY priority ASC, run_at ASC LIMIT 1 FOR UPDATE) RETURNING *
[Worker(host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3)] Job CarrierWave::Workers::StoreAsset (id=22) RUNNING
2015-10-28T23:46:15+0000: [Worker(host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3)] Job CarrierWave::Workers::StoreAsset (id=22) RUNNING
  VehicleImage Load (0.9ms)  SELECT  "vehicle_images".* FROM "vehicle_images" WHERE "vehicle_images"."id" = $1 LIMIT 1  [["id", 93]]
[Worker(host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3)] Job CarrierWave::Workers::StoreAsset (id=22) FAILED (4 prior attempts) with Errno::ENOENT: No such file or directory - /app/public/uploads/tmp/1446075582-3-8474/Cancer_show_034.JPG
2015-10-28T23:46:15+0000: [Worker(host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3)] Job CarrierWave::Workers::StoreAsset (id=22) FAILED (4 prior attempts) with Errno::ENOENT: No such file or directory - /app/public/uploads/tmp/1446075582-3-8474/Cancer_show_034.JPG
   (0.7ms)  BEGIN
  SQL (0.9ms)  UPDATE "delayed_jobs" SET "attempts" = $1, "run_at" = $2, "locked_at" = $3, "locked_by" = $4, "updated_at" = $5 WHERE "delayed_jobs"."id" = $6  [["attempts", 5], ["run_at", "2015-10-28 23:56:45.336065"], ["locked_at", nil], ["locked_by", nil], ["updated_at", "2015-10-28 23:46:15.338022"], ["id", 22]]
   (1.7ms)  COMMIT
  Delayed::Backend::ActiveRecord::Job Load (1.9ms)  UPDATE "delayed_jobs" SET locked_at = '2015-10-28 23:46:15.344057', locked_by = 'host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3' WHERE id IN (SELECT  "delayed_jobs"."id" FROM "delayed_jobs" WHERE ((run_at <= '2015-10-28 23:46:15.343691' AND (locked_at IS NULL OR locked_at < '2015-10-28 19:46:15.343713') OR locked_by = 'host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3') AND failed_at IS NULL)  ORDER BY priority ASC, run_at ASC LIMIT 1 FOR UPDATE) RETURNING *
[Worker(host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3)] 3 jobs processed at 62.5742 j/s, 3 failed
2015-10-28T23:46:15+0000: [Worker(host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3)] 3 jobs processed at 62.5742 j/s, 3 failed
  Delayed::Backend::ActiveRecord::Job Load (1.4ms)  UPDATE "delayed_jobs" SET locked_at = '2015-10-28 23:46:15.347046', locked_by = 'host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3' WHERE id IN (SELECT  "delayed_jobs"."id" FROM "delayed_jobs" WHERE ((run_at <= '2015-10-28 23:46:15.346718' AND (locked_at IS NULL OR locked_at < '2015-10-28 19:46:15.346737') OR locked_by = 'host:7db12935-5a60-41b4-892b-934f088b53d5 pid:3') AND failed_at IS NULL)  ORDER BY priority ASC, run_at ASC LIMIT 1 FOR UPDATE) RETURNING *

config/environments/production.rb

  config.action_mailer.perform_deliveries = true

uploaders/image_uploader.rb

class ImageUploader < CarrierWave::Uploader::Base
  include ::CarrierWave::Backgrounder::Delay

config/initializers/carrierwave_backgrounder.rb

CarrierWave::Backgrounder.configure do |c|
  c.backend :delayed_job, queue: :carrierwave
  # c.backend :resque, queue: :carrierwave
  # c.backend :sidekiq, queue: :carrierwave
  # c.backend :girl_friday, queue: :carrierwave
  # c.backend :sucker_punch, queue: :carrierwave
  # c.backend :qu, queue: :carrierwave
  # c.backend :qc
end

vehicle_image.rb

class VehicleImage < ActiveRecord::Base
  belongs_to :vehicle
  mount_uploader :image, ImageUploader
  process_in_background :image
  store_in_background :image

  def set_to_primary_and_save
    VehicleImage.where(vehicle: vehicle).update_all(primary: false)
    self.primary = true
    save
  end

end

Thanks for looking.

Aucun commentaire:

Enregistrer un commentaire