Capistranoを利用したデプロイ
現在、railsでポートフォリを作成中ですが、エラーが出て詰まっています
bundle exec cap production deploy
とうつとエラーが出ます。
bundle exec cap production deploy --dry-run
ではエラーが出ずにうまくいきます。
(Capistrano編)世界一丁寧なAWS解説。EC2を利用して、RailsアプリをAWSにあげるまで
基本的にはこれを軸に進めています。
発生している問題・エラーメッセージ
00:15 unicorn:restart 01 $HOME/.rbenv/bin/rbenv exec bundle exec unicorn -c /var/www/Oekaki_app/current/config/unicorn/production.rb -E production -D 01 master failed to start, check stderr log for details #<Thread:0x00007fb997b8f328@/Users/sugiuraeiosamu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.20.0/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true): Traceback (most recent call last): 1: from /Users/sugiuraeiosamu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.20.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute' /Users/sugiuraeiosamu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.20.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as ec2-user@18.177.63.188: bundle exit status: 1 (SSHKit::Runner::ExecuteError) bundle stdout: Nothing written bundle stderr: master failed to start, check stderr log for details #<Thread:0x00007fb997b9d9a0@/Users/sugiuraeiosamu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.20.0/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true): Traceback (most recent call last): 1: from /Users/sugiuraeiosamu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.20.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute' /Users/sugiuraeiosamu/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.20.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as ec2-user@18.177.63.188: Exception while executing as ec2-user@18.177.63.188: bundle exit status: 1 (SSHKit::Runner::ExecuteError) bundle stdout: Nothing written bundle stderr: master failed to start, check stderr log for details (Backtrace restricted to imported tasks) cap aborted! SSHKit::Runner::ExecuteError: Exception while executing as ec2-user@18.177.63.188: Exception while executing as ec2-user@18.177.63.188: bundle exit status: 1 bundle stdout: Nothing written bundle stderr: master failed to start, check stderr log for details Caused by: SSHKit::Runner::ExecuteError: Exception while executing as ec2-user@18.177.63.188: bundle exit status: 1 bundle stdout: Nothing written bundle stderr: master failed to start, check stderr log for details Caused by: SSHKit::Command::Failed: bundle exit status: 1 bundle stdout: Nothing written bundle stderr: master failed to start, check stderr log for details /Users/sugiuraeiosamu/environment/Oekaki_app/lib/capistrano/tasks/unicorn.rb:11:in `block in start_unicorn' /Users/sugiuraeiosamu/environment/Oekaki_app/lib/capistrano/tasks/unicorn.rb:10:in `start_unicorn' /Users/sugiuraeiosamu/environment/Oekaki_app/lib/capistrano/tasks/unicorn.rb:47:in `block (3 levels) in <top (required)>' Tasks: TOP => deploy:restart (See full trace by running task with --trace) The deploy has failed with an error: Exception while executing as ec2-user@18.177.63.188: Exception while executing as ec2-user@18.177.63.188: bundle exit status: 1 bundle stdout: Nothing written bundle stderr: master failed to start, check stderr log for details
試したこと
config/deploy/production.rb server "18.177.63.188", user: "ec2-user", roles: %w{web app}, ssh_options: { user: "ec2-user", keys: %w(~/.ssh/aws-and-infra-ssh-key.pem), forward_agent: true, # auth_methods: %w(publickey password) # password: "please use keys" }
検索して上記の書き方が違うのかと思いましたが、全くわかりません。
##追記1
capistrano.log DEBUG [a8c23ee2] Command: cd /var/www/Oekaki_app/releases/20191129055110 && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.1" ; $HOME/.rbenv/bin/rbenv exec bundle check --path /var/www/Oekaki_app/shared/bundle ) DEBUG [a8c23ee2] The following gems are missing DEBUG [a8c23ee2] * net-ssh (5.2.0) DEBUG [a8c23ee2] * net-scp (2.0.0) DEBUG [a8c23ee2] * sshkit (1.20.0) DEBUG [a8c23ee2] * airbrussh (1.4.0) DEBUG [a8c23ee2] * bindex (0.8.1) DEBUG [a8c23ee2] * byebug (11.0.1) DEBUG [a8c23ee2] * capistrano (3.11.2) DEBUG [a8c23ee2] * capistrano-bundler (1.6.0) DEBUG [a8c23ee2] * capistrano-rails (1.4.0) DEBUG [a8c23ee2] * capistrano-rbenv (2.1.4) DEBUG [a8c23ee2] * regexp_parser (1.6.0) DEBUG [a8c23ee2] * xpath (3.2.0) DEBUG [a8c23ee2] * capybara (3.29.0) DEBUG [a8c23ee2] * childprocess (2.0.0) DEBUG [a8c23ee2] * diff-lcs (1.3) DEBUG [a8c23ee2] * dotenv (2.7.5) DEBUG [a8c23ee2] * dotenv-rails (2.7.5) DEBUG [a8c23ee2] * factory_bot (5.1.0) DEBUG [a8c23ee2] * factory_bot_rails (5.1.0) DEBUG [a8c23ee2] * hirb (0.7.3) DEBUG [a8c23ee2] * unicode-display_width (0.1.1) DEBUG [a8c23ee2] * hirb-unicode (0.0.5) DEBUG [a8c23ee2] * ruby_dep (1.5.0) DEBUG [a8c23ee2] * listen (3.1.5) DEBUG [a8c23ee2] * rspec-support (3.8.2) DEBUG [a8c23ee2] * rspec-core (3.8.2) DEBUG [a8c23ee2] * rspec-expectations (3.8.4) DEBUG [a8c23ee2] * rspec-mocks (3.8.1) DEBUG [a8c23ee2] * rspec-rails (3.8.2) DEBUG [a8c23ee2] * rubyzip (1.3.0) DEBUG [a8c23ee2] * selenium-webdriver (3.142.4) DEBUG [a8c23ee2] * spring (2.1.0) DEBUG [a8c23ee2] * spring-watcher-listen (2.0.1) DEBUG [a8c23ee2] * web-console (3.7.0) DEBUG [a8c23ee2] * webdrivers (4.1.2) DEBUG [a8c23ee2] Install missing gems with `bundle install`
Gemfile source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.5.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.3' # Use postgresql as the database for Active Record gem 'pg', '>= 0.18', '< 2.0' # Use Puma as the app server gem 'puma', '~> 3.11' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'mini_racer', platforms: :ruby # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use ActiveStorage variant # gem 'mini_magick', '~> 4.8' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.1.0', require: false group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] gem 'rspec-rails' gem 'factory_bot_rails' gem 'hirb' gem 'hirb-unicode' gem 'dotenv-rails' gem 'capistrano' gem 'capistrano-bundler' gem 'capistrano-rails' gem 'capistrano-rbenv' end group :production, :staging do gem 'unicorn' end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 2.15' # Easy installation and use of chromedriver to run system tests with Chrome # gem 'chromedriver-helper' gem 'webdrivers' gem 'selenium-webdriver' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'slim-rails' gem 'html2slim' gem "bootstrap", "~> 4.3.1" gem 'jquery-rails' gem 'shrine' gem 'devise' gem 'devise-i18n' gem 'devise-i18n-views' gem 'image_processing' gem 'mini_magick' gem 'font-awesome-sass' gem "aws-sdk-s3", require: false gem 'omniauth' gem 'omniauth-twitter'
capistrano.logのエラーを読むと、Gemファイルのgroup :development, :testが
無いってことになりますが、
上記のQiitaだとこれでいいのですが
AWSはこれで大丈夫
だとステージングにGemを追加してます。どうゆうことなんでしょうか
##追記2
unicorn側とnginx側のsockが違っていて治して、更にサーバー側からunicornをkillしたら、最後まで'bundle exec cap production deployが最後までできましたが。 ①サーバー側にインターネットからアクセスすると403エラーになります。 ②また、
bundle exec cap production deploy`をunicornをkillせずにやると追記1と同じエラーが出ます。
Unicornの古いプロセスが消えません
今はこれが気になります。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/11/29 19:43