我正在尝试使用 sidekiq worker ,或多或少将图像文件保存到数据库(使用载波)。要保存的文件很少,它们是从视频文件中提取的关键帧。这就是那个 worker 的意思。
我的图片 uploader 定义了几个版本,如下所示:
class KeyframeUploader < CarrierWave::Uploader::Base
# ...
# Keyframe thumbnail sizes
version :small do
process resize_to_fill: [180, 180], if: :square?
process resize_to_fill: [320, 180], if: :not_square?
end
version :medium do
process resize_to_fill: [460, 460], if: :square?
process resize_to_fill: [640, 460], if: :not_square?
end
version :large do
process resize_to_fill: [720, 720], if: :square?
process resize_to_fill: [1280, 720], if: :not_square?
end
private
# Checks if image is a square
def square? file
img = Magick::Image.read(file.path)
img[0].columns == img[0].rows
end
# Oposite to #square?
def not_square? file
!square? file
end
end
问题是,当我尝试运行我的 Sidekiq Worker 时,它会抛出 Celluloid::FiberStackError: stack level too deep
并且解决这个问题的唯一方法是删除我的版本定义。只有在没有为上传者分配任何版本时它才有效。
我曾尝试将保存过程移至另一个工作人员或使用 Carrierwave::Backgrounder,但我总是得到相同的结果。
你知道我该怎么做吗?
编辑:我的 stracktrace 是:
SystemStackError: stack level too deep from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/irb/workspace.rb:86
最佳答案
事实证明,这是载波的故障(好吧,实际上是 osx 故障)。线程解释:https://github.com/carrierwaveuploader/carrierwave/issues/1330
解决方案:
gem 'rmagick', :require => 'RMagick'
关于ruby-on-rails - 使用载波版本时堆栈级别太深,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22206350/