*目次 [#i7bdbafb]
*関連ページ [#d98e9a99]

*参考情報 [#xcebfe5f]

*capistrano-scm-copyを最初から使う方法 [#ha3bcf1a]

**インストール [#pbd49b81]
gem 'rubyzip'

group :deployment do
  gem 'capistrano'
  gem 'capistrano-rails'
  gem 'capistrano-rbenv'
  gem 'capistrano-bundler'
  gem "capistrano-scm-copy"
 bundle install --path vendor/bundle
-cap install実行
 bundle exec cap install

**設定ファイルの編集 [#pfa01924]
# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'

# Includes tasks from other gems included in your Gemfile
# For documentation on these, see for example:
#   https://github.com/capistrano/rvm
#   https://github.com/capistrano/rbenv
#   https://github.com/capistrano/chruby
#   https://github.com/capistrano/bundler
#   https://github.com/capistrano/rails
# require 'capistrano/rvm'
require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
puts "\n\e[0;31m Are you REALLY sure you want to deploy to production? \e[0m\n"
proceed = STDIN.gets
unless proceed =~ /^y/
  puts "canceld"

set :ssh_options, :forward_agent=>true, :keys=>'~/.ssh/id_rsa.myapp_np', :auth_methods=>%w(publickey)

set :deploy_to, '/Users/sora/www/myapp'
server 'bronze', user: 'sora', roles: %w{web}, my_property: :my_value

role :app, %w{bronze}
role :web, %w{bronze}
role :db,  %w{bronze}


set :application, 'myapp'
set :rbenv_ruby, File.read('.ruby-version').strip

set :scm, :copy
set :include_dir, ["*", '.ruby-version']
set :exclude_dir, ['vendor/bundle', 'log\/*', 'tmp\/*', 'mydb\/*']
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle')

set :keep_releases, 3

task :list do
  on roles(:web) do |host|
    execute "ls"

namespace :deploy do
  namespace :deploy do
    after :restart, :restart_passenger do
      on roles(:web), in: :groups, limit: 3, wait: 10 do
        within release_path do
          execute :touch, 'tmp/restart.txt'
    after :finishing, 'deploy:restart_passenger', 'deploy:cleanup'

**使用する [#oc86e354]
 bundle exec cap production list
 bundle exec cap staging deploy


**設定 [#fddf8ec0]
 gem "capistrano-scm-copy"
 set :scm, :copy
 set :exclude_dir, ['vendor/bundle']
 set :deploy_to, '/home/tanaka/www/demoapp'

 require 'capistrano/copy'
-しかし、[[Appears to try to upload archive file 2x · Issue #17 · wercker/capistrano-scm-copy:https://github.com/wercker/capistrano-scm-copy/issues/17]]によると、処理が2回走ってしまうためrequireしてはならない。
I had the same problem but could find a proper solution; remove require 'capistrano/copy' anywhere!

This problem occurs when we use this module with capistrano/setup because capistrano/setup loads a scm module with the :scm value.

Good luck!

*トラブルシューティング [#b298585a]
-[[IMplement the new Capistrano Scm plugin system · Issue #34 · wercker/capistrano-scm-copy:https://github.com/wercker/capistrano-scm-copy/issues/34]]にあるよに、Capistrano 3.7以降で警告が表示されるようになった。
[Deprecation Notice] `set :scm, :copy` is deprecated.
To ensure this custom SCM will work with future versions of Capistrano,
please upgrade it to a version that uses the new SCM plugin mechanism
documented here:

-[[Capistrano 3 でデプロイサーバから対象サーバにコピー - Qiita:http://qiita.com/Ping/items/57133b6bbb0a3d705fed]]にあるように、[[ydkn/capistrano-git-copy: Capistrano plugin that packages git repository locally and uploads it to server:https://github.com/ydkn/capistrano-git-copy]]を使うのがいいかもしれない。

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS