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
require 'capistrano/rails/migrations'
bundle exec cap staging deploy:migrate
bundle exec cap deploy:cleanup -s keep_releases=3
set :keep_releases, 3 after :finishing, 'deploy:restart_passenger', 'deploy:cleanup'