尽管立即从delay_jobs表中消失了,延迟的作业仍未执行 [英] Delayed job not executed despite disappearing from delayed_jobs table immediately
问题描述
我在指令之后执行了我的Rails应用程序中的延迟工作。
I implemented a delayed job in my Rails application, following the instructions.
- 我启动Rails应用程序
- 我单击一个启动延迟工作的链接
- 该作业在数据库的
delayed_jobs
表中可见 - 我运行
rakejobs:work
- 工作从桌子上消失了,所以我想工作已经完成了
- 但是问题:
/tmp/job.log
尚未编写(作业应完成的工作)
- I start the Rails app
- I click on a link that launches the delayed job
- The job is visible in the database's
delayed_jobs
table - I run
rake jobs:work
- The job disappears from the table, so I guess the job has been performed
- BUT PROBLEM:
/tmp/job.log
has not been written (what the job should have done)
工作:
class CsvImportJob
def perform
File.open('/tmp/job.log', 'w') {|f| f.write("Hello") }
end
end
通话:
job = CsvImportJob.new
job.delay.perform
日志中什么都没有。
rake jobs:work
终端说起始消息后没有任何内容:
Nothing in the logs.
The rake jobs:work
terminal says nothing after its start message:
[Worker(host:nico pid:25453)] Starting job worker
当我启动工作而 rake job:work
是
相反,当执行 hello .delay.length
行时,delay_jobs对其进行处理并出现消息 String#length在0.0556后完成-以3.6912 j / s的速度处理1个作业,失败0个
。
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.
推荐答案
请参见 https:// github.com/collectiveidea/delayed_job/wiki/Common-problems#wiki-un
See https://github.com/collectiveidea/delayed_job/wiki/Common-problems#wiki-undefined_method_xxx_for_class in documentation.
即使延迟工作的作者也不知道原因。它在某种程度上取决于您所运行的Web服务器。尝试Wiki的建议。
Even delayed_job author don't know the reason. It somehow depends on the webserver you run in on. Try the wiki's recommendation.
另请参见 delayed_job:NoMethodError
这篇关于尽管立即从delay_jobs表中消失了,延迟的作业仍未执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!