1

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

然后我调用捆绑安装

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

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

当我运行命令 heroku logs 然后它给我日志时,一个 Web 浏览器打开并显示应用程序错误

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和hopw上遇到这个错误来纠正它?

这是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
4

2 回答 2

2

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

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

有关类似问题,请参阅在 Heroku 上部署 Sinatra 应用程序在 heroku cedar 堆栈上部署 sinatra 应用程序(使用 config.ru) 。

于 2013-02-04T06:42:56.240 回答
1

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

于 2013-02-04T06:42:11.280 回答