質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
unicorn

Unicornは、汎用のRackアプリケーションサーバ。RackとWebサーバーの機能を併せ持ちます。レスポンス処理や、Nginx単体がRackの機能をサポートしていない事から、一般的にはNginx+Unicorn+Railsの構成を取って用います。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Git

Gitはオープンソースの分散バージョン管理システム(DVCS)です。

Amazon EC2

Amazon EC2は“Amazon Elastic Compute Cloud”の略称です。Amazon Web Services(AWS)の一部であり、仮想化されたWebサーバーのコンピュータリソースをレンタルできるサービスです。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

0回答

833閲覧

【緊急】AWS(EC2)で再デプロイする際、unicornの起動時にエラーが発生してしまう。(with_friendly_errors)

退会済みユーザー

退会済みユーザー

総合スコア0

unicorn

Unicornは、汎用のRackアプリケーションサーバ。RackとWebサーバーの機能を併せ持ちます。レスポンス処理や、Nginx単体がRackの機能をサポートしていない事から、一般的にはNginx+Unicorn+Railsの構成を取って用います。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Git

Gitはオープンソースの分散バージョン管理システム(DVCS)です。

Amazon EC2

Amazon EC2は“Amazon Elastic Compute Cloud”の略称です。Amazon Web Services(AWS)の一部であり、仮想化されたWebサーバーのコンピュータリソースをレンタルできるサービスです。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

0クリップ

投稿2021/05/03 09:49

編集2021/05/03 10:32

前提・実現したいこと
unicornを使用してAWSでRailアプリを起動したい。

質問内容
AWSへデプロイしたRailsアプリを再度修正しデプロイし直そうとしたが、unicornが起動できません。

環境
Ruby 2.6.7
Rails 6.0.3.5
AWS(VPC・EC2・RDS・S3・IAM・Route53・ACM使用)※S3は別教材参考に実装。

AWSへデプロイをする際に参考にした記事
https://qiita.com/Yuki_Nagaoka/items/975b7598806d6ae0c0b2
※この記事を参考にhttps化まで全て実装し、一度デプロイ済
※VPC・EC2・RDS・S3・IAM・Route53・ACM使用

コードを編集後に再デプロイする際に参考にした記事
https://laptrinhx.com/aws-ec2nidepuroishitarailsapuriwo-geng-xinsuru-3306149693/
上記サイト参考に変更したアプリを取り込み、bundle installし、プリコンパイルしました。

実行コマンド

server

1bundle exec unicorn_rails -c /var/www/rails/アプリ名/config/unicorn.conf.rb -D -E production

エラーメッセージ

server

1master failed to start, check stderr log for details

server

1エラーログを確認するために下記コマンドを実行 2 3$ cd log 4$ tail unicorn.log

server

1ログ内容 2 from /home/ユーザー名/.rbenv/versions/2.6.7/lib/ruby/gems/2.6.0/gems/bundler-2.2.15/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command' 3 from /home/ユーザー名/.rbenv/versions/2.6.7/lib/ruby/gems/2.6.0/gems/bundler-2.2.15/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch' 4 from /home/ユーザー名/.rbenv/versions/2.6.7/lib/ruby/gems/2.6.0/gems/bundler-2.2.15/lib/bundler/cli.rb:30:in `dispatch' 5 from /home/ユーザー名/.rbenv/versions/2.6.7/lib/ruby/gems/2.6.0/gems/bundler-2.2.15/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start' 6 from /home/ユーザー名/.rbenv/versions/2.6.7/lib/ruby/gems/2.6.0/gems/bundler-2.2.15/lib/bundler/cli.rb:24:in `start' 7 from /home/ユーザー名/.rbenv/versions/2.6.7/lib/ruby/gems/2.6.0/gems/bundler-2.2.15/exe/bundle:49:in `block in <top (required)>' 8 from /home/ユーザー名/.rbenv/versions/2.6.7/lib/ruby/gems/2.6.0/gems/bundler-2.2.15/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors' 9 from /home/ユーザー名/.rbenv/versions/2.6.7/lib/ruby/gems/2.6.0/gems/bundler-2.2.15/exe/bundle:37:in `<top (required)>' 10 from /home/ユーザー名/.rbenv/versions/2.6.7/bin/bundle:23:in `load' 11 from /home/ユーザー名/.rbenv/versions/2.6.7/bin/bundle:23:in `<main>'

with_friendly_errorsというメッセージを発見。

Gemfile

1source 'https://rubygems.org' 2git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 4ruby '2.6.7' 5 6# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7gem 'pg', '>= 0.18', '< 2.0' 8gem 'rails', '~> 6.0.3', '>= 6.0.3.4' 9# Use Puma as the app server 10gem 'puma', '~> 4.1' 11# Use SCSS for stylesheets 12gem 'sass-rails', '>= 6' 13# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker 14gem 'webpacker', '~> 4.0' 15# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 16gem 'turbolinks', '~> 5' 17# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 18gem 'jbuilder', '~> 2.7' 19# Use Redis adapter to run Action Cable in production 20# gem 'redis', '~> 4.0' 21# Use Active Model has_secure_password 22# gem 'bcrypt', '~> 3.1.7' 23gem 'active_decorator' 24gem 'active_model_serializers' 25gem 'annotate' 26gem 'aws-sdk-s3', require: false 27gem 'better_errors' 28gem 'binding_of_caller' 29gem 'devise' 30gem 'faker' 31gem 'hamlit' 32gem 'kaminari' 33gem 'ransack' 34gem 'sidekiq' 35 36# Use Active Storage variant 37gem 'image_processing', '~> 1.2' 38 39# Reduces boot times through caching; required in config/boot.rb 40gem 'bootsnap', '>= 1.4.2', require: false 41 42group :development, :test do 43 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 44 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 45 # gem 'capistrano' 46 # gem 'capistrano-bundler' 47 # gem 'capistrano-rails' 48 # gem 'capistrano-rbenv' 49 gem 'dotenv-rails' 50 gem 'factory_bot_rails' 51 gem 'pry-byebug' 52 gem 'rails-controller-testing' 53 gem 'rails-erd' 54 gem 'rspec-rails' 55 gem 'rubocop-rails' 56end 57 58group :development do 59 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 60 gem 'listen', '~> 3.2' 61 gem 'web-console', '>= 3.3.0' 62 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 63 gem 'erb2haml' 64 gem 'spring' 65 gem 'spring-commands-rspec' 66 gem 'spring-watcher-listen', '~> 2.0.0' 67end 68 69group :test do 70 # Adds support for Capybara system testing and selenium driver 71 gem 'capybara', '>= 2.15' 72 gem 'selenium-webdriver' 73 # Easy installation and use of web drivers to run system tests with browsers 74 gem 'webdrivers' 75end 76 77group :production, :staging do 78 gem 'unicorn' 79end 80 81# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 82gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

試したこと
①一度AWSへデプロイした後に下記記事を元にcapistranoを実装しようとしていたため、そのファイルやGemが他と組み合わせが悪いのかなと仮定し、実装に際して追加したファイルやGemは全て削除

gem: 'capistrano'、'capistrano-bundler'、'capistrano-rails'、'capistrano-rbenv'など
ファイル:Capfileなど

capistrano実装時参考URL:
URLhttps://qiita.com/naoki_mochizuki/items/657aca7531b8948d267b#aws%E5%81%B4%E3%81%AE%E8%A8%AD%E5%AE%9A
→効果なし

②エラーメッセージをもとにfriendly_errorsについて自分と同じような事例を調べてみたが、見つけられず。

エラーログを更に追っていったところ、気になるログを発見。

log

1I, [2021-05-02T11:23:08.340573 #19943] INFO -- : Refreshing Gem list 2bundler: failed to load command: unicorn_rails (/home/ユーザー名/.rbenv/versions/2.6.7/bin/unicorn_rails) 3/home/ユーザー名/.rbenv/versions/2.6.7/lib/ruby/gems/2.6.0/gems/aws-sigv4-1.2.3/lib/aws-sigv4/signer.rb:621:in `extract_credentials_provider': Cannot load `Rails.config.active_storage.service`: (Aws::Sigv4::Errors::MissingCredentialsError) 4missing credentials, provide credentials with one of the following options: 5 - :access_key_id and :secret_access_key 6 - :credentials 7 - :credentials_provider

.envやconfig/database.yml内の環境変数の指定が間違っているのかと思い、確認したが間違いはなさそう。(デプロイ後も何も変更していない)

2日ほど調べたり、再度pullしたりなど試しましたが、解決できませんでした。
就活中にアプリが起動できなくなっておりかなり追い込まれております。。
必要な情報がありましたら急ぎ記載いたします。
力不足で申し訳ございませんが、皆様のお力をお借りしたくお手数ですが、ご確認のほどよろしくお願い申し上げます。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

yu_1985

2021/05/03 16:31 編集

tailだと10行しか見られないので情報が足りません。 オプションで表示行数を増やすか、catやlessなどで広範囲を確認してください。 多分ですけど、調べているところは根本的な原因とは遠いところのように思えます。 また、ログのタイムスタンプと起動しようとして失敗した時の時間帯が一致するかが記載の情報だけではわかりません。 「起動しようとする→その時にログに出るエラー内容を確認する」のステップのほうが確実です。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問