我已经成功地在 heroku cedar stack 上运行 resque 并将接口(interface)挂载到 rails 上。
当我启动 worker 时,一切正常。 worker 处理工作。但是当我杀死 worker 时,Resque 仍然认为 worker 可用。当我启动另一个 worker 时,它认为有 2 个 worker 但实际上只有一个在运行。
我也注意到这里的表格 http://devcenter.heroku.com/articles/ps heroku 在杀死 worker 时发送 SIGTERM,如果没有终止,则发送 SIGKILL。
这是我的 worker 日志
2011-08-11T02:32:45+00:00 heroku[worker.1]: Starting process with command `bundle exec rake resque:work QUEUE=*`
2011-08-11T02:32:46+00:00 heroku[worker.1]: State changed from starting to up
2011-08-11T02:33:58+00:00 heroku[worker.1]: State changed from up to stopping
2011-08-11T02:34:00+00:00 heroku[worker.1]: Stopping process with SIGTERM
2011-08-11T02:34:09+00:00 heroku[worker.1]: Error R12 (Exit timeout) -> Process failed to exit within 10 seconds of SIGTERM
2011-08-11T02:34:09+00:00 heroku[worker.1]: Stopping process with SIGKILL
2011-08-11T02:34:11+00:00 heroku[worker.1]: Process exited
我看到我的进程需要超过 10 秒才能终止。这与我在 worker 任务上加载 rails 环境有什么关系吗?
这是我的 rake 任务 lib/tasks/resque.rake
require "resque/tasks"
task "resque:setup" => :environment
最佳答案
我刚刚发现了问题,在 rake 任务上传递 ENV
时发生了这种情况。就像传递 QUEUE='*'
时一样。
这里是更完整的问题 https://github.com/defunkt/resque/issues/319#issuecomment-1789239
这个问题仍在讨论 https://github.com/defunkt/resque/issues/368
任何我的临时补丁,使 resque 只运行所有 que。
关于ruby-on-rails - worker 终止后,Heroku cedar stack 上的 Resque worker 计数仍然存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7020943/