【问题标题】:Issue deploying Hello World Sinatra app on Heroku.在 Heroku 上部署 Hello World Sinatra 应用程序时出现问题。
【发布时间】:2012-02-03 23:31:11
【问题描述】:

代码如下:

# helloworld.rb

require 'sinatra'

get '/' do
'Hello world! Welcome to the root!'
end

当我部署到 Heroku 时,我会在日志中看到:

2012-02-03T23:18:46+00:00 heroku[web.1]: State changed from crashed to created
2012-02-03T23:18:46+00:00 heroku[web.1]: State changed from created to starting
2012-02-03T23:18:47+00:00 heroku[slugc]: Slug compilation finished
2012-02-03T23:18:48+00:00 heroku[web.1]: Starting process with command `thin -p 17403 -e production -R /home/heroku_rack/heroku.ru start`
2012-02-03T23:18:49+00:00 app[web.1]: <internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- helloworld (LoadError)
2012-02-03T23:18:49+00:00 app[web.1]:   from <internal:lib/rubygems/custom_require>:29:in `require'
2012-02-03T23:18:49+00:00 app[web.1]:   from config.ru:1:in `block (3 levels) in <main>'
2012-02-03T23:18:49+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:23:in `eval'
2012-02-03T23:18:49+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:23:in `block (3 levels) in <main>'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `instance_eval'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:63:in `new'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:63:in `map'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `initialize'
2012-02-03T23:18:49+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:18:in `block (2 levels) in <main>'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `instance_eval'
2012-02-03T23:18:49+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:11:in `new'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `initialize'
2012-02-03T23:18:49+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:11:in `block in <main>'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `instance_eval'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `initialize'
2012-02-03T23:18:49+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:1:in `new'
2012-02-03T23:18:49+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:1:in `<main>'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `eval'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:65:in `start'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `load'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:175:in `load_rackup_config'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:143:in `run!'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:177:in `run_command'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/bin/thin:6:in `<top (required)>'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/bin/thin:19:in `load'
2012-02-03T23:18:49+00:00 app[web.1]:   from /usr/ruby1.9.2/bin/thin:19:in `<main>'
2012-02-03T23:18:50+00:00 heroku[web.1]: State changed from starting to crashed
2012-02-03T23:18:51+00:00 heroku[web.1]: Process exited
2012-02-03T23:18:57+00:00 heroku[router]: Error H10 (App crashed) -> GET alterra.heroku.com/ dyno= queue= wait= service= status=503 bytes=
2012-02-03T23:18:57+00:00 heroku[nginx]: 129.89.10.150 - - [03/Feb/2012:23:18:57 +0000] "GET / HTTP/1.1" 503 607 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.46 Safari/535.11" alterra.heroku.com

我对此完全陌生,所以我认为我做错了什么或忘记包含某些内容。我刚刚收到 H10 应用程序崩溃错误和应用程序错误页面。

【问题讨论】:

  • 更多关于您的期望、您尝试过的内容等细节可能对潜在的回答者有所帮助

标签: git deployment heroku


【解决方案1】:

在你的config.ru你需要改变

require 'helloworld'

require './helloworld'

这是 Ruby 1.9.2 中引入的更改,当前目录不再位于加载路径上。如果这适用于您的本地计算机,那么您可能正在使用 Ruby 1.8.7。如果是这种情况,那么值得考虑升级到 1.9.2。

【讨论】:

  • 太棒了,谢谢!我也没有 Gemfile。我在较新型号的 MacBook Pro 上运行 1.9.2。当我在我的机器上运行 Sinatra 时,它似乎并不关心我是否没有 Gemfile 或 config.ru 文件。其中很多对我来说都是新的。再次感谢!
  • 啊,好的,所以你在本地使用ruby helloworld.rb 运行。如果你想在本地测试你的config.ru,你可以简单地输入rackup,或者如果你安装了Thin,thin start,这就是你可能会在Heroku上使用的。
猜你喜欢
  • 2011-05-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-30
  • 1970-01-01
  • 2012-04-11
  • 1970-01-01
相关资源
最近更新 更多