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

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

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

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

Git

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

GitHub

GitHubは、Gitバージョン管理システムを利用したソフトウェア開発向けの共有ウェブサービスです。GitHub商用プランおよびオープンソースプロジェクト向けの無料アカウントを提供しています。

Amazon EC2

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

Capistrano

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

Q&A

解決済

1回答

2466閲覧

【Capistrano】git stdout: error: cannot open FETCH_HEAD: 許可がありません

sakanafuto

総合スコア0

unicorn

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

Git

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

GitHub

GitHubは、Gitバージョン管理システムを利用したソフトウェア開発向けの共有ウェブサービスです。GitHub商用プランおよびオープンソースプロジェクト向けの無料アカウントを提供しています。

Amazon EC2

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

Capistrano

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

0グッド

0クリップ

投稿2020/07/07 13:49

編集2020/07/08 00:21

##状況

Railsアプリをec2 + nginx + unicorn + capistranoでの自動デプロイに挑戦しているのですが、設定をし終えてbundle exec cap production deployをするとGit周りのエラーが起こってしまいます。

##エラー内容

local

1$ bundle exec cap production deploy 2省略 3(Backtrace restricted to imported tasks) 4cap aborted! 5SSHKit::Runner::ExecuteError: Exception while executing as Stelle@3.112.153.67: git exit status: 1 6git stdout: error: cannot open FETCH_HEAD: 許可がありません 7git stderr: Nothing written

これまでの流れとしては、サーバー上で~から.gitconfigを編集し、その後は以下のとおりです。

server

1[Stelle@ip- ~]$ chmod 700 .ssh 2 3[Stelle@ip- ~]$ cd .ssh 4 5[Stelle@ip- .ssh]$ ssh-keygen -t rsa 6Generating public/private rsa key pair. 7省略 8 9[Stelle@ip- .ssh]$ vim config 10Host github 11 Hostname github.com 12 User git 13 IdentityFile ~/.ssh/xxx_key_rsa 14これで保存 15 16[Stelle@ip- .ssh]$ cat xxx_key_rsa.pub 17Githubにssh接続 18 19[Stelle@ip- .ssh]$ chmod 600 config 20 21[Stelle@ip- .ssh]$ ssh -T github 22Hi sakanafuto! You've successfully authenticated, but GitHub does not provide shell access. 23 24[Stelle@ip- .ssh]$ cd 25 26[Stelle@ip- ~]$ ssh-add ~/.ssh/xxx_key_rsa 27Could not open a connection to your authentication agent. 28 29[Stelle@ip- ~]$ eval "$(ssh-agent)" 30Agent pid 27483 31 32[Stelle@ip- ~]$ ssh-add ~/.ssh/xxx_key_rsa 33Identity added: /home/Stelle/.ssh/xxx_key_rsa (/home/Stelle/.ssh/xxx_key_rsa)

この後にローカルで先程のようにデプロイするとエラーに成ってしまいます。

##該当コード
config/deproy.rb

lock "3.5.0" set :application, "stelle" set :repo_url, "git@github.com:sakanafuto/xxx.git" set :deploy_to, "/var/www/stelle" set :scm, :git set :format, :pretty set :log_level, :debug set :pty, true set :keep_releases, 5 set :rbenv_type, :user set :rbenv_ruby, '2.6.5' 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 :linked_files, fetch(:linked_files, []).push('config/master.key') set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system') set :bundle_jobs, 4 namespace :deploy do desc 'Restart application' task :restart do on roles(:app) do invoke 'unicorn:restart' end end desc 'Create database' task :db_create do on roles(:db) do |host| with rails_env: fetch(:rails_env) do within current_path do execute :bundle, :exec, :rake, 'db:create' end end end end desc 'Run seed' task :seed do on roles(:app) do with rails_env: fetch(:rails_env) do within current_path do execute :bundle, :exec, :rake, 'db:seed' end end end end end after 'deploy:publishing', 'deploy:restart'

config/deploy/production.rb

server '3.xxx.xxx.x', user: 'Stelle', roles: %w{app db web} set :ssh_options, { keys: '~/.ssh/xxx_key_rsa', forward_agent: true }

config/unicorn/production.rb

app_path = '/var/www/stelle' worker_processes 2 working_directory "#{app_path}" + "/current" preload_app true timeout 30 listen "/tmp/sockets/unicorn.sock", :backlog => 64 pid "#{app_path}/shared/tmp/pids/unicorn.pid" # Set the path of the log files inside the log folder of the testapp stderr_path "#{app_path}/current/log/unicorn.stderr.log" stdout_path "#{app_path}/current/log/unicorn.stdout.log" before_fork do |server, worker| ENV['BUNDLE_GEMFILE'] = File.expand_path('Gemfile', ENV['RAILS_ROOT']) end before_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! old_pid = "#{server.config[:pid]}.oldbin" if old_pid != server.pid begin sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU Process.kill(sig, File.read(old_pid).to_i) rescue Errno::ENOENT, Errno::ESRCH end end sleep 1 end after_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end

Capfile

require "capistrano/setup" require "capistrano/deploy" # require "capistrano/scm/git" # install_plugin Capistrano::SCM::Git require "capistrano/rbenv" require "capistrano/rails" require "capistrano/rails/assets" require "capistrano/rails/migrations" require "capistrano/bundler" require "capistrano3/unicorn" Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

Gemfile

gem 'capistrano', '~>3.5.0' gem 'capistrano-bundler', '~> 1.1.3' gem 'capistrano-rails', '~> 1.1.7' gem 'capistrano-rbenv' gem 'capistrano3-unicorn'

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

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

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

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

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

siruku6

2020/07/07 23:58

設定ファイル「deploy.rb」と「production.rb」は質問文に掲載しておきましょう gitの設定がどちらかには書かれているはずで、そこに手掛かりがありそうです
sakanafuto

2020/07/08 00:21

コードをいくつか追加しました!
guest

回答1

0

自己解決

サーバ側でsudo chown -R () .で出来ました。

投稿2020/07/21 07:12

sakanafuto

総合スコア0

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問