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

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

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails 5

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

Capistrano

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

Q&A

0回答

262閲覧

capistrano3 でのデプロイでエラーが出てしまい解決出来ずに困っていますのでご教示お願いします。

koume

総合スコア458

Ruby on Rails 5

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

Capistrano

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

0グッド

0クリップ

投稿2019/03/21 13:19

Railsアプリをデプロイしようとcapistrano3の設定をしていますが、サイトなどを参考にしながら
いろいろファイルの設定をしましたが、エラーが多発して嵌ってしまいました。
設定環境
ローカル
Rails5.1.3
vagrant
capistrano3.11.0

VPS
さくらのVPS
CentOS7
apache
passenger
port 60258
IPアドレス 155.128.133.89

[vagrant@localhost chibi]$ bundle exec cap production deploy:check を実行すると

[8e1b8f91] Running /usr/bin/env which passenger as panda@155.128.133.89 DEBUG [8e1b8f91] Command: /usr/bin/env which passenger (Backtrace restricted to imported tasks) cap aborted! SSHKit::Runner::ExecuteError: Exception while executing as panda@155.128.133.89: Authentication failed for user panda@155.128.133.89 Net::SSH::AuthenticationFailed: Authentication failed for user panda@155.128.133.89 Tasks: TOP => rvm:hook => passenger:rvm:hook => passenger:test_which_passenger (See full trace by running task with --trace) と表示されます。

[vagrant@localhost chibi]$ bundle exec cap production deploy を実行すると

(Backtrace restricted to imported tasks) cap aborted! Don't know how to build task 'deploy:upload' (see --tasks) Tasks: TOP => deploy:starting (See full trace by running task with --trace) と表示されます。

capistranoの設定ファイル内容は以下になります。

Capfile require "capistrano/setup" require "capistrano/deploy" require "capistrano/scm/git" install_plugin Capistrano::SCM::Git require "capistrano/setup" require "capistrano/deploy" require 'capistrano/rails' require 'capistrano/rvm' require 'capistrano/rbenv' require 'capistrano/chruby' require 'capistrano/bundler' require 'capistrano/rails/assets' require 'capistrano/rails/migrations' require 'capistrano/passenger' require 'capistrano/puma' require 'sshkit/sudo' require 'whenever/capistrano' require "capistrano/maintenance" Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r } install_plugin Capistrano::Puma
config/deploy.rb lock "~> 3.11.0" set :application, "chibi" set :rails_env, "production" set :repo_url, "git@example.com:me/my_repo.git" set :branch, 'master' set :conditionally_migrate, true set :whenever_identifier, ->{ "#{fetch(:application)}_#{fetch(:stage)}" } set :user, 'panda' set :puma_threads, [4, 16] set :puma_workers, 0 set :pty, true set :use_sudo, false set :stage, :production set :deploy_via, :remote_cache set :deploy_to, "/var/www/html" set :format, :pretty set :log_level, :debug set :keep_releases, 3 set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock" set :puma_state, "#{shared_path}/tmp/pids/puma.state" set :puma_pid, "#{shared_path}/tmp/pids/puma.pid" set :puma_access_log, "#{release_path}/log/puma.access.log" set :puma_error_log, "#{release_path}/log/puma.error.log" set :puma_preload_app, true set :puma_worker_timeout, nil set :puma_init_active_record, true set :rbenv_type, :user set :rbenv_path, '/usr/local/rbenv' set :rbenv_ruby, '2.3.1-p112' set :chruby_ruby, 'ruby-2.3.1-p112' set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec" set :rbenv_map_bins, %w{rake gem bundle ruby rails} set :rbenv_roles, :all set :linked_dirs, fetch(:linked_dirs, []).push( 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads' ) set :linked_files, fetch(:linked_files, []).push( 'config/database.yml', 'config/secrets.yml', '.env' ) set :whenever_identifier, -> { "#{fetch(:application)}_#{fetch(:stage)}" } set :passenger_rvm_ruby_version, '2.3.1-p112' set :passenger_environment_variables, { :path => '/path-to-passenger/bin:$PATH' } set :passenger_restart_command, "/path-to-passenger/bin/passenger-config restart-app #{deploy_to}" set :passenger_restart_with_touch, true namespace :puma do desc 'Create Directories for Puma Pids and Socket' task :make_dirs do on roles(:app) do execute "mkdir #{shared_path}/tmp/sockets -p" execute "mkdir #{shared_path}/tmp/pids -p" end end before :start, :make_dirs end namespace :deploy do desc 'Make sure local git is in sync with remote.' task :check_revision do on roles(:app) do unless `git rev-parse HEAD` == `git rev-parse origin/master` end end end desc 'Initial Deploy' task :initial do on roles(:app) do before 'deploy:restart', 'puma:start' invoke 'deploy' end end desc 'Restart application' task :restart do on roles(:app), in: :sequence, wait: 5 do Rake::Task["puma:restart"].reenable invoke! 'puma:restart' end end desc "Resterts application." task :restart do on roles :all do execute :mkdir, "-p :#{shared_path}/tmp" execute :touch, "#{shared_path}/tmp/restart.txt" end end desc 'reload the database with seed data' task :seed do on roles(:db) do with rails_env: fetch(:rails_env) do within release_path do execute :bundle, :exec, :rake, 'db:seed' end end end end after :migrate, :seed before :starting, :check_revision after :finishing, :compile_assets after :finishing, :cleanup end before 'deploy:starting', 'deploy:upload' after 'deploy:publishing', 'deploy:restart' require "capistrano/maintenance" set :maintenance_template_path, File.join(File.dirname(__FILE__), "..", "app", "views", "system", "maintenance.html.erb") $VERBOSE = nil namespace :db do desc "Dump the database and compress it." task :backup do on roles(:db) do #task :backup, :roles => :db, :only => { :primary => true } do backups_path = "#{shared_path}/db_backups" date = capture "cat #{current_path}/config/database.yml" config = YAML::load(data)[rails_env] abort unless config && config['adapter'] == 'mysql2' file_name = "#{config['database']}-#{release_name}.sql.gz" command = "/usr/bin/mysqldump --user=#{config['username']}" command += " --password" if config['password'] command += " --host=#{config['host']}" if config['host'] command += " --port=#{config['port']}" if config['port'] command += " #{config['database']}" command += " | gzip -c > #{backups_path}/#{file_name}" run "mkdir -p #{backups_path}" run command do |channel, _, output| if output =~ /^Enter password:/ channel.send_data "#{config['password']}n" end end end end end Rake::Task["deploy:new_release_path"].clear namespace :deploy do task :new_release_path do set_release_path(Time.now.strftime("%Y%m%d%H%M%S")) end end
config/deploy/production.rb set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock" set :puma_state, "#{shared_path}/tmp/pids/puma.state" set :puma_pid, "#{shared_path}/tmp/pids/puma.pid" set :puma_access_log, "#{release_path}/log/puma.access.log" set :puma_error_log, "#{release_path}/log/puma.error.log" set :puma_preload_app, true set :puma_worker_timeout, nil set :puma_init_active_record, true set :stage, :production set :rails_env, 'production' set :branch, 'master' set :migration_role, 'db' server '155.128.133.89', user: 'panda', roles: %w{app web db} set :ssh_options, { port: 60258, keys: [File.expand_path('~/.ssh/id_rsa')], #VPSの公開鍵 forward_agent: true, auth_methods: %w(publickey) }

解決方法のご教示お願いします。

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

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

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

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

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

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

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

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

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問