ruby-on-rails - 如何在 heroku 上调试 "Error R10 (Boot timeout)"问题

标签 ruby-on-rails heroku

我感兴趣的是,要了解在阻止启动的那 60 秒内发生的情况以及导致此问题的常见原因,需要采取哪些步骤。

这是日志文件的样子(没有说明实际发生了什么)

2013-01-14T10:34:17+00:00 app[web.1]: => Booting Thin
2013-01-14T10:34:17+00:00 app[web.1]: => Call with -d to detach
2013-01-14T10:34:17+00:00 app[web.1]: => Rails 3.2.2 application starting in production on http://0.0.0.0:52216
2013-01-14T10:34:17+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-01-14T10:34:23+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2013-01-14T10:34:23+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-01-14T10:34:24+00:00 heroku[web.1]: Process exited with status 137
2013-01-14T10:34:24+00:00 heroku[web.1]: State changed from starting to crashed

我认为如果至少有一个堆栈跟踪显示进程何时被终止,那将非常有帮助。

发生这种情况时您会做什么/检查什么?

PS:我不是在寻找我的案例的答案,而是在寻找一般步骤,每个人都可以从中受益。

最佳答案

我通常首先使用以下代码 (initializers/debug_require.rb) 找出哪些 gem 花费了很长时间:

if ENV['DEBUG_REQUIRE']
  require 'benchmark'

  def require(file)
    @@first ||= Time.now
    rc = false
    ts = Benchmark.measure do
      rc = super
    end
    if ENV['DEBUG_REQUIRE'].to_f < ts.total
      total = ts.format("%t require #{file}")
      from_start = (Time.now - @@first).to_i
      $stdout.puts "#{total} (#{from_start} second(s) from start)"
    end
    rc
  end
end

将此添加到 config/boot.rb:

require File.expand_path('../initializers/debug_require', __FILE__)

并设置heroku config:add DEBUG_REQUIRE=1

观察日志输出是否需要慢速。

关于ruby-on-rails - 如何在 heroku 上调试 "Error R10 (Boot timeout)"问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14317078/

相关文章:

ruby-on-rails - 缺少必需的选项 :name

mysql - Rails 错误 - 没有要加载的此类文件 -- mysql

php - Cakephp Heroku插件路径错误

node.js - 如何解决我的 heroku 应用程序上的 "Not Secure"警告?

ruby-on-rails - ruby json新换行符渲染格式不正确

ruby-on-rails - 如何为不在模型文件夹根目录中的模型定义 Rails 中的工厂女孩​​?

ruby-on-rails - ActionController::Session::CookieStore::CookieOverflow 发送 csv/xls 文件时 - rails 2.3.5

python - Django错误: 'myproject.wsgi.application' could not be loaded

ruby-on-rails - 在 Heroku 上使用瘦服务器部署 Rails 应用程序时出现 "No such file or directory"错误

python - 在 MacOS 上安装 Django-tool belt 的错误消息