Heroku Sinatra 应用程序反复崩溃且无法使用控制台
我在尝试将 Sinatra 应用程序部署到 Heroku 时遇到问题 - 这是我第一次使用 Sinatra 和 Heroku。
我有一个 .gems 文件,其中一行:“sinatra”,以及一个 config.ru 文件,其中包含以下几行:
require 'myapplication'
run Sinatra::Application
推送到 heroku 并导航到 url 后,我收到一个页面,上面写着“App Crashed”和以下文本:
此应用程序暂时 离线。如果您是管理员 要使用此应用程序,请检查您的 heroku 回溯日志。
“heroku log”的输出是:
2011-02-10T01:33:24-08:00 app[web.1]: from ./myapplication.rb:3
2011-02-10T01:33:24-08:00 app[web.1]: from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
2011-02-10T01:33:24-08:00 app[web.1]: from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
require'
2011-02-10T01:33:24-08:00 app[web.1]: from config.ru:2
<-- TEXT SNIPPED -->
2011-02-10T01:33:24-08:00 app[web.1]: from /home/heroku_rack/heroku.ru:1:in `new'
2011-02-10T01:33:24-08:00 app[web.1]: from /home/heroku_rack/heroku.ru:1
2011-02-10T01:33:25-08:00 heroku[web.1]: State changed from starting to crashed
2011-02-10T01:33:32-08:00 heroku[nginx]: GET / HTTP/1.1 | 75.56.61.69 | 3310 | http | 500
其中 myapplication.rb 的第三行是“require 'models'”,其中“models.rb”与“myapplication.rb”存在于同一目录中。
此外,每当我运行“heroku console”命令时,我都会收到以下信息:
Your application is too busy to open a console session. Console sessions require an open dyno to use for execution.
我尝试了各种选项来尝试消除此问题,但尚未成功。
感谢您提供的任何帮助!
I'm having trouble with a Sinatra application which I'm trying to deploy to Heroku - this is my first time with Sinatra and Heroku.
I have a .gems file with one line: "sinatra" as well as a config.ru file with the following lines:
require 'myapplication'
run Sinatra::Application
After pushing to heroku and navigating to the url I receive a page that says "App Crashed" and the following text:
This application is temporarily
offline. If you're the administrator
of this app, please check your heroku
logs for the backtrace.
The output from "heroku logs" is:
2011-02-10T01:33:24-08:00 app[web.1]: from ./myapplication.rb:3
2011-02-10T01:33:24-08:00 app[web.1]: from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
2011-02-10T01:33:24-08:00 app[web.1]: from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
require'
2011-02-10T01:33:24-08:00 app[web.1]: from config.ru:2
<-- TEXT SNIPPED -->
2011-02-10T01:33:24-08:00 app[web.1]: from /home/heroku_rack/heroku.ru:1:in `new'
2011-02-10T01:33:24-08:00 app[web.1]: from /home/heroku_rack/heroku.ru:1
2011-02-10T01:33:25-08:00 heroku[web.1]: State changed from starting to crashed
2011-02-10T01:33:32-08:00 heroku[nginx]: GET / HTTP/1.1 | 75.56.61.69 | 3310 | http | 500
Where the 3rd line of the myapplication.rb is a "require 'models'" where "models.rb" exists in the same directory as "myapplication.rb".
Also whenever I run the "heroku console" command, I receive the following:
Your application is too busy to open a console session. Console sessions require an open dyno to use for execution.
I've tried various options to try to get this to go away but haven't succeeded yet.
Thanks for any help offered!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了同样的问题,所以这不是完整的答案,但也许会有所帮助。如果您只是使用
heroku log
,您只会得到大约 20(或者可能是 50)行输出。您的错误跟踪看起来不像是从实际错误开始的,因为它是从“from”开始的,根据我有限的经验,这表明它不是源头。如果您还没有这样做,请尝试使用heroku logs -n 200
或更多来获取更长的跟踪,并搜索“Errno”或“ERROR”等。它对解决控制台问题没有帮助,但至少可以告诉您应用程序无法运行的原因。I am having the same problem, so this is not a full answer, but perhaps it will help. If you simply used
heroku logs
, you only get something like 20 (or perhaps it's 50) lines of output. Your error trace does not look like it starts from the actual error, since it begins "from" which, in my limited experience, indicates that it's not the source. If you haven't already, tryheroku logs -n 200
or more to get a longer trace, and search for "Errno" or "ERROR" and so on. It won't help with the console issue, but at least it might tell you why your app is not working.如果您正在使用 Ruby 1.9.x(而不是旧的 1.8.x)版本的 Ruby 的 Heroku 堆栈之一上运行,请注意 1.9 中的新“require_relative”指令,您必须使用该指令来引用文件在相对于当前文件的路径中。
这让我很困惑,因为我在本地使用 1.8.x 进行开发,
如果你希望它同时适用于 1.8.x 和 1.9.x,你可以这样做:
If you're running on one of the Heroku stacks that uses Ruby 1.9.x (as opposed to the older 1.8.x) versions of Ruby, be aware of the new "require_relative" directive with 1.9, which you must use to reference files in paths relative to your current file.
This tripped me up, because I was locally developing with 1.8.x
If you want it to work for both 1.8.x and 1.9.x, you could do something like: