加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Carrierwave backgrounder sidekiq没有工人

发布时间:2020-12-17 02:44:59 所属栏目:百科 来源:网络整理
导读:我在本地设置了carrierwave背景资源以及sidekiq和sidekiq网站.我可以看到作业被添加到sidekiq Enqueued但它们永远不会运行.什么会妨碍他们执行? 建立: Rails 3.2.11 Unicorn 4.6.1 Sidekiq 2.7.5 carrierwave 0.8.0 carrierwave_backgrounder 0.2.0 配置背
我在本地设置了carrierwave背景资源以及sidekiq和sidekiq网站.我可以看到作业被添加到sidekiq Enqueued但它们永远不会运行.什么会妨碍他们执行?

建立:
Rails 3.2.11
Unicorn 4.6.1
Sidekiq 2.7.5
carrierwave 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,"#222221"]

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

  version :thumblarge do
    process :resize_and_pad => [640,360,"#222221"]
  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
 => []

配置/ sidekiq.yml

:concurrency: 1

配置/初始化/ 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

感谢您的帮助 :)

解决方法

好的,我错误地开始了sidekiq. -q需要设置为队列名称.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读