【问题标题】:Carrierwave backgrounder sidekiq no workersCarrierwave 背景程序 sidekiq 没有工人
【发布时间】:2013-02-26 20:01:24
【问题描述】:

我已经在本地设置了carrierwave 背景程序以及sidekiq 和sidekiq web。我可以看到已将作业添加到 sidekiq Enqueued 但它们从未运行。什么会阻止他们执行?

设置: 导轨 3.2.11 独角兽 4.6.1 Sidekiq 2.7.5 载波 0.8.0 carrierwave_backgrounder 0.2.0

后台配置。

CarrierWave::Backgrounder.configure do |c|
  c.backend :sidekiq, queue: :carrierwave
end

型号

class EntryImage < ActiveRecord::Base
  attr_accessible :alt, :image_path

  belongs_to :imageable, :polymorphic => true

  validates :image_path, presence: true

  mount_uploader :image_path, ImageUploader
  process_in_background :image_path


end

上传者

# encoding: utf-8

class ImageUploader < CarrierWave::Uploader::Base
  include ::CarrierWave::Backgrounder::Delay
  # Include RMagick or MiniMagick support:
  # include CarrierWave::RMagick
  include CarrierWave::MiniMagick

  # Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
  # include Sprockets::Helpers::RailsHelper
  # include Sprockets::Helpers::IsolatedHelper

  # Choose what kind of storage to use for this uploader:
  if Rails.env.test?
    storage :file
  else
    storage :fog
  end

  # Override the directory where uploaded files will be stored.
  # This is a sensible default for uploaders that are meant to be mounted:
  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

  # Provide a default URL as a default if there hasn't been a file uploaded:
  # def default_url
  #   # For Rails 3.1+ asset pipeline compatibility:
  #   # asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
  #
  #   "/images/fallback/" + [version_name, "default.png"].compact.join('_')
  # end

  # Process files as they are uploaded:
  # process :scale => [200, 300]
  #
  # def scale(width, height)
  #   # do something
  # end

  # Create different versions of your uploaded files:
  # version :thumb do
  #   process :scale => [50, 50]
  # end
  process :resize_and_pad => [1280, 720, "#111111"]

  version :thumb do
    process :resize_and_pad => [384,216, "#111111"]
  end

  version :thumblarge do
    process :resize_and_pad => [640,360, "#111111"]
  end

  # Add a white list of extensions which are allowed to be uploaded.
  # For images you might use something like this:
  def extension_white_list
     %w(jpg jpeg gif png)
  end

  # Override the filename of the uploaded files:
  # Avoid using model.id or version_name here, see uploader/store.rb for details.
  # def filename
  #   "something.jpg" if original_filename
  # end

end

检查注册工人返回空白

1.9.3p194 :006 > Sidekiq::Client.registered_workers
 => [] 

config/sidekiq.yml

:concurrency: 1

config/initializer/sidekiq.rb

require 'sidekiq'

Sidekiq.configure_client do |config|
  config.redis = { :size => 1 }
end

Sidekiq.configure_server do |config|
  # The config.redis is calculated by the
  # concurrency value so you do not need to
  # specify this. For this demo I do
  # show it to understand the numbers
  config.redis = { :size => 3 }
end

我也通过几种方式从命令行启动了 sidekiq

bundle exec sidekiq -q high,5 default
bundle exec sidekiq

感谢您的帮助:)

【问题讨论】:

    标签: ruby-on-rails carrierwave sidekiq


    【解决方案1】:

    好的,我错误地启动了 sidekiq。 -q 需要设置为队列名称。

    【讨论】:

    • 经历过同样的事情。阅读您的帖子后 - 这样做了:bundle exec sidekiq -q carrierwave,5 default。谢谢队友
    • 这里也一样,帮我省了几个小时的挫折
    猜你喜欢
    • 1970-01-01
    • 2015-05-17
    • 2012-09-30
    • 1970-01-01
    • 2011-05-24
    • 2017-05-20
    • 2013-12-30
    • 2021-01-09
    • 1970-01-01
    相关资源
    最近更新 更多