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

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

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

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

Ruby on Rails 5

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

Capistrano

Rubyで書かれたサーバオーケストレーションで、複数のサーバでスクリプトを実行する際に用いられます。主な使用用途はWebアプリケーションのデプロイメントです。 アプリケーションのバージョンアップ自動化、およびデータベースの変更などもできます。

React.js

Reactは、アプリケーションのインターフェースを構築するためのオープンソースJavaScriptライブラリです。

Q&A

解決済

1回答

1484閲覧

capistranoを使ったrails+reactのデプロイがうまくいかない

susiyaki

総合スコア39

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

Ruby on Rails 5

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

Capistrano

Rubyで書かれたサーバオーケストレーションで、複数のサーバでスクリプトを実行する際に用いられます。主な使用用途はWebアプリケーションのデプロイメントです。 アプリケーションのバージョンアップ自動化、およびデータベースの変更などもできます。

React.js

Reactは、アプリケーションのインターフェースを構築するためのオープンソースJavaScriptライブラリです。

0グッド

1クリップ

投稿2019/06/16 22:10

編集2019/06/17 07:00

質問1

問題

VPSサーバ側で /var/www/blog_app/releases/20190616214753 に移動して、

export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.1" ; $HOME/.rbenv/bin/rbenv exec bundle check --path /var/www/blog_app/shared/bundle ``` を実行した場合は問題なく終了したのですが、 `bundle exec cap production deproy` をした際にはうまく通っていないようです。 色々調べてみたのですが解決できないので協力お願いします。 ## 環境

ruby 2.5.1
rails 5.2.3
capistrano 3.11.0
conoha VPS利用

## 参考にしたサイト > https://qiita.com/ryo2132/items/f62690f0b16ec11270fe#6-4-nginx%E3%81%AE%E8%87%AA%E5%8B%95%E8%B5%B7%E5%8B%95%E8%A8%AD%E5%AE%9A ## ログファイル ```log ...略 DEBUG [ffc51f1f] Command: ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.1" ; /usr/bin/env ln -s /var/www/blog_app/shared/public/assets /var/www/blog_app/releases/20190616214753/public/assets ) INFO [834c7ae4] Finished in 0.129 seconds with exit status 0 (successful). DEBUG [58edf984] Running if test ! -d /var/www/blog_app/releases/20190616214753; then echo "Directory does not exist '/var/www/blog_app/releases/20190616214753'" 1>&2; false; fi as hoge@111.11.11.111 DEBUG [58edf984] Command: if test ! -d /var/www/blog_app/releases/20190616214753; then echo "Directory does not exist '/var/www/blog_app/releases/20190616214753'" 1>&2; false; fi DEBUG [d6631c93] Finished in 0.460 seconds with exit status 0 (successful). DEBUG [0b5645f0] Running $HOME/.rbenv/bin/rbenv exec bundle check --path /var/www/blog_app/shared/bundle as hoge@111.11.11.111 DEBUG [0b5645f0] Command: cd /var/www/blog_app/releases/20190616214753 && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.1" ; $HOME/.rbenv/bin/rbenv exec bundle check --path /var/www/blog_app/shared/bundle ) DEBUG [2ac3b608] The following gems are missing * net-ssh (5.2.0) * net-scp (2.0.0) * sshkit (1.18.2) * airbrussh (1.3.2) * io-like (0.3.0) * archive-zip (0.12.0) DEBUG [2ac3b608] * bcrypt_pbkdf (1.0.1) * bindex (0.7.0) DEBUG [2ac3b608] * byebug (11.0.1) * capistrano (3.11.0) * capistrano-bundler (1.5.0) * capistrano-rails (1.4.0) DEBUG [2ac3b608] * capistrano-rbenv (2.1.4) DEBUG [2ac3b608] * capistrano-yarn (2.0.2) DEBUG [2ac3b608] * regexp_parser (1.5.1) * xpath (3.2.0) * capybara (3.24.0) DEBUG [2ac3b608] * childprocess (1.0.1) DEBUG [2ac3b608] * chromedriver-helper (2.1.1) * ed25519 (1.2.4) * foreman (0.85.0) DEBUG [2ac3b608] * ruby_dep (1.5.0) * listen (3.1.5) * rubyzip (1.2.3) * selenium-webdriver (3.142.3) * spring (2.1.0) DEBUG [2ac3b608] * spring-watcher-listen (2.0.1) DEBUG [2ac3b608] * web-console (3.7.0) Install missing gems with `bundle install` DEBUG [2ac3b608] Finished in 0.467 seconds with exit status 1 (failed). INFO [ae8f670b] Running $HOME/.rbenv/bin/rbenv exec bundle install --path /var/www/blog_app/shared/bundle --jobs 4 --without development test --deployment --quiet as hoge@111.11.11.111 DEBUG [ae8f670b] Command: cd /var/www/blog_app/releases/20190616214753 && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.1" ; $HOME/.rbenv/bin/rbenv exec bundle install --path /var/www/blog_app/shared/bundle --jobs 4 --without development test --deployment --quiet ) INFO [d01ec368] Finished in 0.548 seconds with exit status 0 (successful). DEBUG [dd5450f4] Running if test ! -d /var/www/blog_app/releases/20190616214753; then echo "Directory does not exist '/var/www/blog_app/releases/20190616214753'" 1>&2; false; fi as hoge@111.11.11.111 DEBUG [dd5450f4] Command: if test ! -d /var/www/blog_app/releases/20190616214753; then echo "Directory does not exist '/var/www/blog_app/releases/20190616214753'" 1>&2; false; fi DEBUG [1170e9e2] Finished in 0.492 seconds with exit status 0 (successful). INFO [7dfbc613] Running /usr/bin/env yarn install --prefer-offline --production --no-progress as hoge@111.11.11.111 DEBUG [7dfbc613] Command: cd /var/www/blog_app/releases/20190616214753 && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.1" ; /usr/bin/env yarn install --prefer-offline --production --no-progress ) DEBUG [cbdf4afb] yarn install v1.16.0 DEBUG [cbdf4afb] [1/4] Resolving packages... DEBUG [cbdf4afb] [2/4] Fetching packages... DEBUG [cbdf4afb] info fsevents@1.2.9: The platform "linux" is incompatible with this module. DEBUG [cbdf4afb] info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation. DEBUG [cbdf4afb] [3/4] Linking dependencies... DEBUG [cbdf4afb] [4/4] Building fresh packages... DEBUG [cbdf4afb] Done in 17.50s. INFO [cbdf4afb] Finished in 18.004 seconds with exit status 0 (successful).

質問2

上記の参考サイト等を元にnginxの設定ファイルを書いたのですが、capistranoでデプロイしたらcurrentディレクトリは勝手に作成されるのでしょうか?
デプロイが通っていないのでどういう動作をするのかわからず、疑問に感じています。

/etc/nginx/nginx.conf

user nginx; Done in 7.31s. [susiyaki@118-27-35-159 20190616212403]$ cd user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; include /etc/nginx/conf.d/*.conf; }

/etc/nginx/conf.d/blog_app.conf

#各種ログのディレクトリ設定 error_log /var/www/blog_app/current/log/nginx.error.log; access_log /var/www/blog_app/current/log/nginx.access.log; #処理を受け取る最大許容量 client_max_body_size 2G; upstream app_server { # 連携するunicornのソケットのパス server unix:/var/www/blog_app/current/tmp/sockets/.unicorn.sock fail_timeout=0; } server { listen 80; server_name 111.11.11.111; # conohaのipアドレス #次のリクエストが来るまでの待ち時間(秒 keepalive_timeout 5; #静的ファイルを読みに行くディレクトリ root /var/www/blog_app/current/public; #キャッシュのディレクトリ try_files $uri/index.html $uri.html $uri @app; location @app { # HTTP headers proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app_server; } #エラーページを設置する場所 error_page 500 502 503 504 /500.html; location = /500.html { root /var/www/blog_app/current/public; } }

追記

エラーログを見返すと、group->test, developmentのgemでエラーが出ているようです。
どうすれば消えるでしょうか?

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 mysql as the database for Active Record gem 'mysql2', '>= 0.4.4', '< 0.6.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 # 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 # authenticate gem 'devise' gem 'cancancan' # admin-page gem 'activeadmin' # markdown gem 'redcarpet' # syntax highlight gem 'rouge' # markdown realtime preview gem 'backbone-on-rails' gem 'marked-rails' # locale gem 'rails-i18n', '~> 5.1' # pv gem 'redis' gem 'redis-objects' gem 'whenever', require: false # chart gem 'chart-js-rails' gem 'gon' # image uploader gem 'carrierwave' gem 'rmagick' # use react gem 'react_on_rails' gem 'webpacker' # use bootstrap4 gem 'bootstrap' gem 'jquery-rails' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console # gem 'redis', '~> 4.0' # gem 'redis', '~> 4.0' gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 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' gem 'foreman' gem 'capistrano' gem 'capistrano-bundler' gem 'capistrano-rails' gem 'capistrano-rbenv' gem 'ed25519' gem 'bcrypt_pbkdf' end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 2.15' gem 'selenium-webdriver' # Easy installation and use of chromedriver to run system tests with Chrome gem 'chromedriver-helper' end group :production, :staging do gem 'unicorn' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

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

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

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

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

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

guest

回答1

0

自己解決

config/deproy.rb内のdeproyタスク内のこの記述をコメントアウトしたら通りました

# namespace :webpack do # after "yarn:install", "webpack:build" # task :build do # on roles(:app) do # execute "cd #{release_path} && #{fetch :yarn_bin} run build:prod" # end # end # end

投稿2019/06/17 07:31

susiyaki

総合スコア39

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.49%

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

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

質問する

関連した質問