I implemented a delayed job in my Rails application, following the instructions.
- I start the Rails app
- I click on a link that launches the delayed job
- The job is visible in the database’s
delayed_jobstable - I run
rake jobs:work - The job disappears from the table, so I guess the job has been performed
- BUT PROBLEM:
/tmp/job.loghas not been written (what the job should have done)
The job:
class CsvImportJob
def perform
File.open('/tmp/job.log', 'w') {|f| f.write("Hello") }
end
end
The call:
job = CsvImportJob.new
job.delay.perform
Nothing in the logs.
The rake jobs:work terminal says nothing after its start message:
[Worker(host:nico pid:25453)] Starting job worker
Nothing happen either when I launch the job while rake jobs:work is running.
In contrast, when the line "hello".delay.length is executed, delayed_jobs processes it and a message String#length completed after 0.0556 - 1 jobs processed at 3.6912 j/s, 0 failed does appear.
See https://github.com/collectiveidea/delayed_job/wiki/Common-problems#wiki-undefined_method_xxx_for_class in documentation.
Even delayed_job author don’t know the reason. It somehow depends on the webserver you run in on. Try the wiki’s recommendation.
See also delayed_job: NoMethodError