gpt4 book ai didi

ruby - Sinatra 应用程序的 Heroku 生产问题(错误 R10)

转载 作者:太空宇宙 更新时间:2023-11-03 18:21:47 24 4
gpt4 key购买 nike

我按照 heroku 的说明仔细部署了一个 Sinatra 应用程序,但仍然出现问题。如果有任何区别,我正在使用 sinatra-base 和 sinatra-partial。我在 gemfile 和 myapp.rb 中声明了所有的 gems

Gist of my files

这是我在 heroku 日志上看到的

2013-06-11T05:09:28.982664+00:00 app[web.1]:    from myapp.rb:49:in `<class:MyApp>'
2013-06-11T05:09:29.148291+00:00 app[web.1]: [2013-06-11 05:09:29] INFO WEBrick 1.3.1
2013-06-11T05:09:29.148613+00:00 app[web.1]: == Sinatra/1.4.0 has taken the stage on 4567 for production with backup from WEBrick
2013-06-11T05:09:29.148759+00:00 app[web.1]: [2013-06-11 05:09:29] INFO WEBrick::HTTPServer#start: pid=2 port=4567
2013-06-11T05:09:29.148291+00:00 app[web.1]: [2013-06-11 05:09:29] INFO ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-06-11T05:10:26.570140+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2013-06-11T05:10:26.570414+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-06-11T05:10:28.018692+00:00 heroku[web.1]: Process exited with status 137
2013-06-11T05:10:28.033080+00:00 heroku[web.1]: State changed from starting to crashed

在对 Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 错误做了更多研究后,可能是因为 gems 需要很长时间加载时间。但是,我只使用这些 gem ,所以我不知道为什么会超时。在本地,启动我的应用程序大约需要 1 秒。

最佳答案

Heroku 动态分配端口。当您调用 myapp.rb 第 85-97 行中的 run! 方法时,您将在端口 4567 上启动应用程序。您应该能够删除这三行并使用 config.ru 启动您的应用。

如果将 heroku gem 添加到 Gemfile 中,则可以删除 Procfile。否则你应该改变它通过备份启动应用程序:

web: bundle exec rackup config.ru -p $PORT

您还可以在 Gemfile 中添加 'thin' 并使用这样的 Procfile

web: bundle exec thin start -R config.ru -e $RACK_ENV -p $PORT

关于ruby - Sinatra 应用程序的 Heroku 生产问题(错误 R10),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17036951/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com