前提・実現したいこと
herokuのApplication errorを解決してherokuにデプロイしたい。
現在railsチュートリアルの7章をしており後半にある本番環境へのデプロイという項目でつまづいています。
手順通りに進めていてSSLを使うためにproduciton.rbで
config.force_ssl = true
と記述し、config/puma.rbでは
workers Integer(ENV['WEB_CONCURRENCY'] || 2) threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5) threads threads_count, threads_count preload_app! rackup DefaultRackup port ENV['PORT'] || 3000 environment ENV['RACK_ENV'] || 'development' on_worker_boot do # Worker specific setup for Rails 4.1+ # See: https://devcenter.heroku.com/articles/ # deploying-rails-applications-with-the-puma-web-server#on-worker-boot ActiveRecord::Base.establish_connection end
と記述し、Gemfileと同じディレクトリにProcfileを作り
web: bundle exec puma -C config/puma.rb
と記述しました。
そして
$ rails test $ git add -A $ git commit -m "Use SSL and the Puma webserver in production" $ git push $ git push heroku $ heroku run rails db:migrate $ heroku open
としたところ下記のエラーが!
発生している問題・エラーメッセージ
Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command heroku logs --tail
該当のソースコード
heroku logs --tailをすると以下のようなログが出てきた
2018-11-22T11:34:40.086650+00:00 app[web.1]: /app/vendor/bundle/ruby/2.5.0/bin/puma:23:in `<top (required)>' 2018-11-22T11:34:40.226396+00:00 heroku[web.1]: State changed from starting to up 2018-11-22T11:34:40.325090+00:00 heroku[web.1]: Process exited with status 1 2018-11-22T11:34:40.344523+00:00 heroku[web.1]: State changed from up to crashed 2018-11-22T11:34:40.346434+00:00 heroku[web.1]: State changed from crashed to starting 2018-11-22T11:34:45.832518+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb` 2018-11-22T11:34:48.927632+00:00 app[web.1]: [4] Puma starting in cluster mode... 2018-11-22T11:34:48.927676+00:00 app[web.1]: [4] * Version 3.12.0 (ruby 2.5.1-p57), codename: Llamas in Pajamas 2018-11-22T11:34:48.927679+00:00 app[web.1]: [4] * Min threads: 5, max threads: 5 2018-11-22T11:34:48.927685+00:00 app[web.1]: [4] * Environment: production 2018-11-22T11:34:48.927687+00:00 app[web.1]: [4] * Process workers: 2 2018-11-22T11:34:48.927689+00:00 app[web.1]: [4] * Preloading application 2018-11-22T11:34:52.913838+00:00 app[web.1]: [4] * Listening on tcp://0.0.0.0:51726 2018-11-22T11:34:52.914067+00:00 app[web.1]: [4] * Listening on tcp://0.0.0.0:51726 2018-11-22T11:34:52.914320+00:00 app[web.1]: bundler: failed to load command: puma (/app/vendor/bundle/ruby/2.5.0/bin/puma) 2018-11-22T11:34:52.914349+00:00 app[web.1]: Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 51726 2018-11-22T11:34:53.124010+00:00 heroku[web.1]: State changed from starting to crashed 2018-11-22T11:34:53.103282+00:00 heroku[web.1]: Process exited with status 1 2018-11-22T11:34:58.961604+00:00 app[api]: Starting process with command `rails db:migrate` by user k8t2y9.cat@gmail.com 2018-11-22T11:35:03.224704+00:00 heroku[run.4141]: Awaiting client 2018-11-22T11:35:03.258519+00:00 heroku[run.4141]: Starting process with command `rails db:migrate` 2018-11-22T11:35:03.525543+00:00 heroku[run.4141]: State changed from starting to up 2018-11-22T11:35:09.819836+00:00 heroku[run.4141]: Process exited with status 0 2018-11-22T11:35:09.837067+00:00 heroku[run.4141]: State changed from up to complete 2018-11-22T11:35:23.106081+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=radiant-ridge-30387.herokuapp.com request_id=1c0490e3-eb04-45c1-98ed-abafb1358ebf fwd="60.100.247.250" dyno= connect= service= status=503 bytes= protocol=https 2018-11-22T11:35:23.775653+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=radiant-ridge-30387.herokuapp.com request_id=d9105058-eddd-427b-b8d9-5a5b5cd66932 fwd="60.100.247.250" dyno= connect= service= status=503 bytes= protocol=https 2018-11-22T11:36:33.769854+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=radiant-ridge-30387.herokuapp.com request_id=ebbe82d6-9987-4ee1-b825-33d5952964d9 fwd="60.100.247.250" dyno= connect= service= status=503 bytes= protocol=https 2018-11-22T11:36:34.179219+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=radiant-ridge-30387.herokuapp.com request_id=75347f38-9984-4e4a-913a-2b0fbb247bdf fwd="60.100.247.250" dyno= connect= service= status=503 bytes= protocol=https
試したこと
ググってGemfileの下を
group :production do gem 'pg', '< 1.0.0' end
にするといいとあったがそれをしても変わらない。
またrails sをしたところこれもエラーが出て
Address already in use - bind(2) for "0.0.0.0" port 3000 (Errno::EADDRINUSE)
となってしまった。
どうか手助けお願いします。
あなたの回答
tips
プレビュー