正在工作而不是在后台运行任务
我遵循 railscast 描述如何让工作运行后台任务,但不能让它发挥作用。该任务运行,但不在后台运行(在我重定向到 admin_path 之前需要 5 秒)。
我的代码如下所示:
类 AdminWorker <工作::基地
def test_workling(选项)
睡5
结束
结束类AdminController <应用程序控制器
def test_workling
AdminWorker.asynch_test_workling
flash[:notice] = "在后台做一些事情"
重定向到管理路径
结束
结束
我做错了什么?如何调试?
谢谢!
I followed the railscast that describes how to get workling running background tasks, but can't get it working. The task runs, but not in the background (it's taking 5 secs before I'm redirected to admin_path).
Here is what my code looks like:
class AdminWorker < Workling::Base
def test_workling(options)
sleep 5
end
endclass AdminController < ApplicationController
def test_workling
AdminWorker.asynch_test_workling
flash[:notice] = "Doing stuff in the background"
redirect_to admin_path
end
end
What am I doing wrong? How to debug?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现我已经以正确的方式设置了工作:
在 /config/environment.rb 中,我有:
Workling::Remote.dispatcher = Workling::Remote::Runners::NotRemoteRunner.new
while我应该有:
Workling::Remote.dispatcher = Workling::Remote::Runners::StarlingRunner.new
更改后一切都非常顺利
I found out I had set up workling the right way:
in /config/environment.rb, I had:
Workling::Remote.dispatcher = Workling::Remote::Runners::NotRemoteRunner.new
while I was supposed to have:
Workling::Remote.dispatcher = Workling::Remote::Runners::StarlingRunner.new
It all went very smoothly after that change