rails delayed_pa​​perclip process_in_background无效

时间:2013-12-03 10:39:44

标签: ruby-on-rails mongoid paperclip delayed-job

我有一个有图片的附件模型(定义的其余部分存在,但下面的行足够了)

has_mongoid_attached_file :picture

我想通过使用名为“process_in_background”的方法的“delayed_pa​​perclip”gem来调整大小调整过程:

process_in_background :picture

然后我开始了一个前台日志记录工作者:

./script/delayed_job run
delayed_job: process with pid 32393 started.

然后将文件发布到特定网址以上传文件并查看结果,但没有发生任何特殊情况。与工作人员一起上传的文件。 甚至我停止了工作人员并重新发布文件然后执行:

rake jobs:workoff

但没有任何人在排队!

即使我在puts "hello world"(在gem源代码中)的process_in_background方法的开头放了delayed_paperclip.rb,但没有记录任何意味着它没有被执行。

我该如何解决这个问题? TNX。

更新: 我的服务器日志:

Command :: file -b --mime '/tmp/120131203-2768-q7a6cz20131203-2768-15kecj3'
  MOPED: 127.0.0.1:27017 COMMAND      database=project_development command={:findAndModify=>"delayed_backend_mongoid_jobs", :query=>{"run_at"=>{"$lte"=>2013-12-03 10:58:26 UTC}, "failed_at"=>nil, "$or"=>[{"locked_by"=>"host:BlackBox pid:3113"}, {"locked_at"=>nil}, {"locked_at"=>{"$lt"=>2013-12-03 06:58:26 UTC}}]}, :new=>true, :sort=>{"locked_by"=>-1, "priority"=>1, "run_at"=>1}, :update=>{"$set"=>{:locked_at=>2013-12-03 10:58:26 UTC, :locked_by=>"host:BlackBox pid:3113"}}} (0.9518ms)
  MOPED: 127.0.0.1:27017 COMMAND      database=project_development command={:findAndModify=>"delayed_backend_mongoid_jobs", :query=>{"run_at"=>{"$lte"=>2013-12-03 10:58:31 UTC}, "failed_at"=>nil, "$or"=>[{"locked_by"=>"host:BlackBox pid:3113"}, {"locked_at"=>nil}, {"locked_at"=>{"$lt"=>2013-12-03 06:58:31 UTC}}]}, :new=>true, :sort=>{"locked_by"=>-1, "priority"=>1, "run_at"=>1}, :update=>{"$set"=>{:locked_at=>2013-12-03 10:58:31 UTC, :locked_by=>"host:BlackBox pid:3113"}}} (1.0488ms)
  MOPED: 127.0.0.1:27017 COMMAND      database=project_development command={:findAndModify=>"delayed_backend_mongoid_jobs", :query=>{"run_at"=>{"$lte"=>2013-12-03 10:58:36 UTC}, "failed_at"=>nil, "$or"=>[{"locked_by"=>"host:BlackBox pid:3113"}, {"locked_at"=>nil}, {"locked_at"=>{"$lt"=>2013-12-03 06:58:36 UTC}}]}, :new=>true, :sort=>{"locked_by"=>-1, "priority"=>1, "run_at"=>1}, :update=>{"$set"=>{:locked_at=>2013-12-03 10:58:36 UTC, :locked_by=>"host:BlackBox pid:3113"}}} (1.0679ms)
  MOPED: 127.0.0.1:27017 COMMAND      database=project_development command={:findAndModify=>"delayed_backend_mongoid_jobs", :query=>{"run_at"=>{"$lte"=>2013-12-03 10:58:41 UTC}, "failed_at"=>nil, "$or"=>[{"locked_by"=>"host:BlackBox pid:3113"}, {"locked_at"=>nil}, {"locked_at"=>{"$lt"=>2013-12-03 06:58:41 UTC}}]}, :new=>true, :sort=>{"locked_by"=>-1, "priority"=>1, "run_at"=>1}, :update=>{"$set"=>{:locked_at=>2013-12-03 10:58:41 UTC, :locked_by=>"host:BlackBox pid:3113"}}} (1.0037ms)
  MOPED: 127.0.0.1:27017 COMMAND      database=project_development command={:findAndModify=>"delayed_backend_mongoid_jobs", :query=>{"run_at"=>{"$lte"=>2013-12-03 10:58:46 UTC}, "failed_at"=>nil, "$or"=>[{"locked_by"=>"host:BlackBox pid:3113"}, {"locked_at"=>nil}, {"locked_at"=>{"$lt"=>2013-12-03 06:58:46 UTC}}]}, :new=>true, :sort=>{"locked_by"=>-1, "priority"=>1, "run_at"=>1}, :update=>{"$set"=>{:locked_at=>2013-12-03 10:58:46 UTC, :locked_by=>"host:BlackBox pid:3113"}}} (1.1113ms)
  MOPED: 127.0.0.1:27017 COMMAND      database=project_development command={:findAndModify=>"delayed_backend_mongoid_jobs", :query=>{"run_at"=>{"$lte"=>2013-12-03 10:58:51 UTC}, "failed_at"=>nil, "$or"=>[{"locked_by"=>"host:BlackBox pid:3113"}, {"locked_at"=>nil}, {"locked_at"=>{"$lt"=>2013-12-03 06:58:51 UTC}}]}, :new=>true, :sort=>{"locked_by"=>-1, "priority"=>1, "run_at"=>1}, :update=>{"$set"=>{:locked_at=>2013-12-03 10:58:51 UTC, :locked_by=>"host:BlackBox pid:3113"}}} (1.7586ms)
  MOPED: 127.0.0.1:27017 COMMAND      database=project_development command={:findAndModify=>"delayed_backend_mongoid_jobs", :query=>{"run_at"=>{"$lte"=>2013-12-03 10:58:56 UTC}, "failed_at"=>nil, "$or"=>[{"locked_by"=>"host:BlackBox pid:3113"}, {"locked_at"=>nil}, {"locked_at"=>{"$lt"=>2013-12-03 06:58:56 UTC}}]}, :new=>true, :sort=>{"locked_by"=>-1, "priority"=>1, "run_at"=>1}, :update=>{"$set"=>{:locked_at=>2013-12-03 10:58:56 UTC, :locked_by=>"host:BlackBox pid:3113"}}} (1.0285ms)

1 个答案:

答案 0 :(得分:1)

即使paperclip支持mongoid,delayed_pa​​perclip也不支持。 我做了一个delayed_pa​​perclip的小分支来支持mongoid。它没有单元测试,因此可能是错误的,但它确实为我做了工作。 只需将include DelayedPaperclip::MongoidGlue行添加到您的模型中即可。

https://github.com/RedXVII/delayed_paperclip/tree/mongoid-support