delay_job-不执行最新代码? [英] delayed_job - Performs not up to date code?
问题描述
我在site5.com共享托管上使用了delay_job(尝试了tobi和collection_idea),并以乘客作为轨道环境。
我设法完成工作。
但是,似乎插件在首次运行后会忽略作业类源代码中的任何更改。
每次更改后,我都会重新启动服务器( touch tmp / restart.txt
),但它仍然忽略它。
I'm using delayed_job (tried both tobi's and collective_idea's) on site5.com shared hosting, with passenger as rails environment.
I managed to make jobs done.
However, it seems the plugin ignores any changes in a job class source code after first run.
I have restarted the server on every change (touch tmp/restart.txt
) but it still ignores it.
示例:
文件: lib / xx_job.rb
class XxJob
def perform
Rails.logger.info "XX START"
TempTest.delete_all
i = 0
10.times {
i+=1
TempTest.create(:name => "XXX")
sleep(1)
}
Rails.logger.info "XX END"
end
end
在一个简单的控制器中,我调用:
In a simple controller I call:
Delayed::Job.enqueue(XxJob.new)
我收集的结论:
- 如果我将xx_job.rb更改为xx_job1.rb-控制器错误
- 如果我将XxJob类更改为XxJob1-控制器错误
- 如果我删除所有perform方法内容-旧代码执行旧代码
- 带有.c的新.rb文件不好意思地执行,使该类入队-完美地工作
- 如果我在新文件的执行中再次更改了内容并再次运行作业-执行了旧代码
- If I change xx_job.rb to xx_job1.rb - error on the controller
- If I change class XxJob to class XxJob1 - error on the controller
- If I delete all the perform method content - the old code old code is executed
- New .rb file with class and perform, enqueue this class - works perfectly
- If I change something in that new file's perform and run job again - old code is executed
在每次更改之间,我为服务器重新启动。
似乎是乘客或其他东西保存了类缓存。
Between every change I made a restart for the server. It seems like Passenger or something else saves class cache.
如何删除该缓存?是存储在服务器上的某个地方吗? (我希望我可以从共享主机访问它)
How can I delete this cache? Is is stored on the server somewhere? (I hope I have access to it from the shared hosting)
谢谢!
推荐答案
最终,我发现了这一点-几名工人在后台运行,他们每个人抓到一份工作并拥有自己的缓存。
我不知道如何杀死他们,所以我改变了桌子的名字几秒钟。那杀死了他们:)
Eventually I figured that out - several workers were running in background, each of them caught a job and had their own cache. I didn't know how to kill them so I changed the table's name for several seconds. That killed them :)
然后我使用了在工作人员启动时,https://github.com/tobi/delayed_job/wiki/Running-Delayed :: Worker-as-a-daemon ,效果很好
Then I used https://github.com/tobi/delayed_job/wiki/Running-Delayed::Worker-as-a-daemon as worker start, and it works great.
这篇关于delay_job-不执行最新代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!