Tag: Capistrano3
以下bundle経由で使用する方法を説明する。
group :deployment do gem 'capistrano' gem 'capistrano-rails' gem 'capistrano-rbenv' gem 'capistrano-bundler' end
bundle install --path vendor/bundle
$ cd myproject $ bundle exec cap install mkdir -p config/deploy create config/deploy.rb create config/deploy/staging.rb create config/deploy/production.rb mkdir -p lib/capistrano/tasks Capified
# 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 }
server 'centos6vm', user: 'tanaka', roles: %w{app db web}, my_property: :my_value role :app, %w{tanaka@centos6vm} role :web, %w{tanaka@centos6vm} role :db, %w{tanaka@centos6vm}
set :application, 'demoapp' set :rbenv_ruby, File.read('.ruby-version').strip set :scm, :copy set :tar_roles, :web set :exclude_dir, ['vendor/bundle'] set :bundle_flags, '--quiet' task :list do on roles(:web) do execute "ls" end end 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' end end end after :finishing, 'deploy:restart_passenger' end end
bundle exec cap staging list
bundle exec cap staging deploy
bundle exec cap deploy:cleanup -s keep_releases=3
set :keep_releases, 3 after :finishing, 'deploy:restart_passenger', 'deploy:cleanup'
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' end end end after :finishing, 'deploy:restart_passenger' end end
TODO:
gem "capistrano-scm-copy"
set :scm, :copy set :exclude_dir, ['vendor/bundle']
set :deploy_to, '/home/tanaka/www/demoapp'
require 'capistrano/copy'
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. https://github.com/capistrano/capistrano/blob/master/lib/capistrano/setup.rb#L18 Good luck!
group :deployment do gem 'capistrano', '~> 3.0', require: false gem 'rubyzip', require: false end
require 'zip' Zip.setup do |c| c.unicode_names = true c.on_exists_proc = true c.continue_on_exists_proc = true end namespace :copy do task :check do end task :set_current_revision do end task create_release: 'release.zip' do |t| file = t.prerequisites.first on roles(:app) do execute :mkdir, '-p', fetch(:tmp_dir) upload! file, fetch(:tmp_dir) execute :unzip, '-o', "#{fetch(:tmp_dir)}/release.zip", '-d', release_path end File.delete file if File.exists?(file) end file 'release.zip' do |t| release_filename = File.join(Dir.pwd, t.name) Dir.chdir fetch(:copy_dir) do Zip::File.open(release_filename, Zip::File::CREATE) do |zipfile| files = FileList['**/*'] files.exclude(*fetch(:copy_exclude)).each do |file| zipfile.add(file, file) end end end end end
set :scm, 'copy' set :copy_dir, '.' set :tmp_dir, '/tmp' set :copy_exclude, [ /\.log$/, %r!^files/.+! ]
set :copy_exclude, [ /^logs/, /^tmp/, /^vendor/ ]
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/uploads')
role :app, %w{deploy@example.com} role :web, %w{deploy@example.com} role :db, %w{deploy@example.com} # Extended Server Syntax # ====================== # This can be used to drop a more detailed server definition into the # server list. The second argument is a, or duck-types, Hash and is # used to set extended properties on the server. server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value
sudo apt-get install nodejs sudo yum install nodejs
gem.files = `git ls-files`.split($\)
ssh-add -D