在heroku上部署简单的机架应用程序时出现应用程序错误

时间:2013-02-04 05:44:42

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

我正在尝试在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 with code

web: bundle exec rackup config.ru

然后我调用bundle install

之后的机架配置 它按预期完美地工作 但之后我尝试在heroku上部署它并获得应用程序错误 我执行了以下命令

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

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

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

2 个答案:

答案 0 :(得分:2)

看起来您没有为要运行的应用指定正确的端口。尝试将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

答案 1 :(得分:1)

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