【问题标题】:Application Error when deploying a simple rack application on heroku在 Heroku 上部署简单的机架应用程序时出现应用程序错误
【发布时间】:2013-01-18 19:33:15
【问题描述】:

我正在尝试在 heroku 上部署我的应用程序 它包含5个文件 1.config.ru 带代码

require 'rack'
require './myapp'

run MyApp.new

2.Gemfile 带代码

source "http://rubygems.org"
gem 'grape'
gem 'sequel'
gem 'heroku'
gem 'rake'
gem 'pg'
gem 'rack'
group :test do
  gem "rspec", "~> 2.12.0"
  gem "rack-test", "~> 0.6.2"
  gem "rspec-core", "~> 2.12.2"
  gem "rspec-expectations", "~> 2.12.1"
  gem "rspec-mocks", "~> 2.12.1"
  gem "capybara", "~> 2.0.2"
  gem "nokogiri", "~> 1.5.6"
end

3.自动创建的Gemfile.lock 4.myapp.rb 带代码

# my_app.rb
class MyApp
  def call env
    [200, {"Content-Type" => "text/html"}, ["Hello Rack Participants"]] 
  end
end

5.Procfile 和代码

web: bundle exec rackup config.ru

然后我调用捆绑安装

在那之后 config.ru 它按预期工作得很好 但之后我尝试在heroku上部署它并得到应用程序错误 我为此执行了以下命令

git init
git add .
git commit -m "initial commit"
heroku create
git push heroku master
heroku open

Web 浏览器打开时出现应用程序错误 当我运行命令 heroku logs 然后它给我日志

2013-02-04T05:34:17+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=quiet-caverns-8170.herokuapp.com fwd=121.245.34.235 dyno= queue= wait= connect= service= status=503 bytes=

谁能帮助我为什么在heroku上遇到这个错误并希望纠正它??

这里是heroku的完整日志

2013-02-04T05:30:44+00:00 heroku[api]: Scale to web=1 by ritesh@iritesh.com
2013-02-04T05:30:44+00:00 heroku[api]: Attach HEROKU_POSTGRESQL_CYAN resource by ritesh@iritesh.com
2013-02-04T05:30:44+00:00 heroku[api]: Release v3 created by ritesh@iritesh.com
2013-02-04T05:30:45+00:00 heroku[api]: Add DATABASE_URL config by ritesh@iritesh.com
2013-02-04T05:30:45+00:00 heroku[api]: Release v4 created by ritesh@iritesh.com
2013-02-04T05:30:45+00:00 heroku[api]: Add  config by ritesh@iritesh.com
2013-02-04T05:30:45+00:00 heroku[api]: Release v5 created by ritesh@iritesh.com
2013-02-04T05:30:45+00:00 heroku[api]: Release v6 created by ritesh@iritesh.com
2013-02-04T05:30:45+00:00 heroku[api]: Deploy 243e86c by ritesh@iritesh.com
2013-02-04T05:30:51+00:00 heroku[web.1]: Starting process with command `bundle exec ruby web.rb`
2013-02-04T05:30:52+00:00 app[web.1]: bash: bundle: command not found
2013-02-04T05:30:53+00:00 heroku[web.1]: Process exited with status 127
2013-02-04T05:30:56+00:00 heroku[web.1]: Starting process with command `bundle exec ruby web.rb`
2013-02-04T05:30:58+00:00 app[web.1]: ruby: No such file or directory -- web.rb (LoadError)
2013-02-04T05:31:00+00:00 heroku[web.1]: Process exited with status 1
2013-02-04T05:31:00+00:00 heroku[web.1]: State changed from starting to crashed
2013-02-04T05:31:00+00:00 heroku[web.1]: State changed from crashed to starting
2013-02-04T05:31:13+00:00 heroku[web.1]: Starting process with command `bundle exec ruby web.rb`
2013-02-04T05:31:19+00:00 heroku[web.1]: State changed from starting to crashed
2013-02-04T05:31:22+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=quiet-caverns-8170.herokuapp.com fwd=121.245.34.235 dyno= queue= wait= connect= service= status=503 bytes=
2013-02-04T05:31:22+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=quiet-caverns-8170.herokuapp.com fwd=121.245.34.235 dyno= queue= wait= connect= service= status=503 bytes=
2013-02-04T05:31:18+00:00 app[web.1]: ruby: No such file or directory -- web.rb (LoadError)
2013-02-04T05:31:19+00:00 heroku[web.1]: Process exited with status 1
2013-02-04T05:33:42+00:00 heroku[slugc]: Slug compilation started
2013-02-04T05:33:52+00:00 heroku[api]: Release v7 created by ritesh@iritesh.com
2013-02-04T05:33:52+00:00 heroku[api]: Deploy eb490fb by ritesh@iritesh.com
2013-02-04T05:33:52+00:00 heroku[web.1]: State changed from crashed to starting
2013-02-04T05:33:53+00:00 heroku[slugc]: Slug compilation finished
2013-02-04T05:33:59+00:00 heroku[web.1]: State changed from starting to crashed
2013-02-04T05:34:17+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=quiet-caverns-8170.herokuapp.com fwd=121.245.34.235 dyno= queue= wait= connect= service= status=503 bytes=
2013-02-04T05:33:55+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru`
2013-02-04T05:33:58+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-02-04T05:33:57+00:00 app[web.1]: [2013-02-04 05:33:57] INFO  WEBrick::HTTPServer#start: pid=2 port=9292
2013-02-04T05:33:58+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 9292, should be 16705 (see environment variable PORT)
2013-02-04T05:33:57+00:00 app[web.1]: [2013-02-04 05:33:57] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-02-04T05:33:57+00:00 app[web.1]: [2013-02-04 05:33:57] INFO  WEBrick 1.3.1
2013-02-04T05:33:59+00:00 heroku[web.1]: Process exited with status 137
2013-02-04T05:41:22+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru`
2013-02-04T05:41:19+00:00 heroku[web.1]: State changed from crashed to starting
2013-02-04T05:41:24+00:00 app[web.1]: [2013-02-04 05:41:24] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-02-04T05:41:24+00:00 app[web.1]: [2013-02-04 05:41:24] INFO  WEBrick 1.3.1
2013-02-04T05:41:24+00:00 app[web.1]: [2013-02-04 05:41:24] INFO  WEBrick::HTTPServer#start: pid=2 port=9292
2013-02-04T05:41:25+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-02-04T05:41:25+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 9292, should be 46347 (see environment variable PORT)
2013-02-04T05:41:26+00:00 heroku[web.1]: Process exited with status 137
2013-02-04T05:41:26+00:00 heroku[web.1]: State changed from starting to crashed
2013-02-04T05:51:59+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 9292, should be 15335 (see environment variable PORT)
2013-02-04T05:51:57+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru`
2013-02-04T05:51:59+00:00 app[web.1]: [2013-02-04 05:51:59] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-02-04T05:51:59+00:00 app[web.1]: [2013-02-04 05:51:59] INFO  WEBrick 1.3.1
2013-02-04T05:51:59+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-02-04T05:51:59+00:00 app[web.1]: [2013-02-04 05:51:59] INFO  WEBrick::HTTPServer#start: pid=2 port=9292
2013-02-04T05:52:01+00:00 hero
ku[web.1]: Process exited with status 137
2013-02-04T05:55:18+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=quiet-caverns-8170.herokuapp.com fwd=121.245.34.235 dyno= queue= wait= connect= service= status=503 bytes=
2013-02-04T05:55:19+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=quiet-caverns-8170.herokuapp.com fwd=121.245.34.235 dyno= queue= wait= connect= service= status=503 bytes=
2013-02-04T06:01:58+00:00 heroku[web.1]: State changed from crashed to starting
2013-02-04T06:02:04+00:00 heroku[web.1]: State changed from starting to crashed
2013-02-04T06:12:11+00:00 heroku[web.1]: State changed from crashed to starting
2013-02-04T06:12:14+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru`
2013-02-04T06:12:18+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-02-04T06:12:17+00:00 app[web.1]: [2013-02-04 06:12:17] INFO  WEBrick 1.3.1
2013-02-04T06:12:17+00:00 app[web.1]: [2013-02-04 06:12:17] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-02-04T06:12:17+00:00 app[web.1]: [2013-02-04 06:12:17] INFO  WEBrick::HTTPServer#start: pid=2 port=9292
2013-02-04T06:12:18+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 9292, should be 35684 (see environment variable PORT)
2013-02-04T06:12:19+00:00 heroku[web.1]: State changed from starting to crashed
2013-02-04T06:12:19+00:00 heroku[web.1]: Process exited with status 137

【问题讨论】:

  • 我会查看您发布的行之前和之后的行,有时会有更多信息。当我不得不执行 db:migrate but for to 时,我遇到了类似的问题。
  • 不,您可以看到没有数据库迁移,它是一个简单的 rake 应用程序等待发布完整日志
  • 现在请帮助我为什么会收到此错误
  • 它说“bundle: command not found”,如果它是一个 rails 应用程序 heroku 知道并在运行 bundle install 和启动 rails 之前安装 bundler;你试过没有procfile吗?

标签: ruby-on-rails heroku rack heroku-toolbelt heroku-san


【解决方案1】:

您似乎没有为应用程序指定正确的运行端口。尝试将您的 Procfile 切换到以下内容

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

有关类似问题,请参阅 Deploy Sinatra app on HerokuDeploying sinatra app (with config.ru) on heroku cedar stack

【讨论】:

    【解决方案2】:

    您没有绑定到$PORT 中的端口,因此我们终止了您的进程。您必须更改您的 Procfile 以包含 -p $PORT

    【讨论】:

      猜你喜欢
      • 2018-05-30
      • 1970-01-01
      • 2021-03-25
      • 2018-11-23
      • 2018-08-16
      • 1970-01-01
      • 2017-02-04
      • 2013-02-15
      • 1970-01-01
      相关资源
      最近更新 更多