Reputation: 1012
I have an attachment model having a picture(the rest of the definition exist but line below is enough)
has_mongoid_attached_file :picture
I want to make the resizing process happen at background by using "delayed_paperclip" gem having a method named "process_in_background" :
process_in_background :picture
and then I started a foreground logging worker:
./script/delayed_job run
delayed_job: process with pid 32393 started.
and then posted a file to a specific url to upload the file and see the results but nothing special happened. file uploaded with the worker logging nothing. even I stopped the worker and reposted the file and then executed:
rake jobs:workoff
but nothing was in queue!
even I put a puts "hello world"
in the beginning of process_in_background method in the delayed_paperclip.rb
(in the gem source code) but nothing logged meaning that it is not being executed.
How can i fix this problem? tnx.
UPDATE: my server log:
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)
Upvotes: 0
Views: 1488
Reputation: 877
Even though paperclip supports mongoid, delayed_paperclip does not.
I did a small branch of delayed_paperclip to support mongoid though. It has no unit test and as such might be buggy, but it did the job for me.
Just add the include DelayedPaperclip::MongoidGlue
line to your model.
https://github.com/RedXVII/delayed_paperclip/tree/mongoid-support
Upvotes: 1