建立:
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: :carrIErwaveend
模型
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_pathend
上传
# enCoding: utf-8class 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 # endend
检查注册工人是空的
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 }endSIDekiq.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 defaultbundle exec sIDekiq
感谢您的帮助 :)
解决方法 好的,我错误地开始了sIDekiq. -q需要设置为队列名称. 总结以上是内存溢出为你收集整理的ruby-on-rails – Carrierwave backgrounder sidekiq没有工人全部内容,希望文章能够帮你解决ruby-on-rails – Carrierwave backgrounder sidekiq没有工人所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)