Capistrano v3 configuration example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined. | |
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple Role Syntax | |
# ================== | |
# Supports bulk-adding hosts to roles, the primary server in each group | |
# is considered to be the first unless any hosts have the primary | |
# property set. Don't declare `role :all`, it's a meta role. | |
role :app, %w{root@my-project.com} | |
role :web, %w{root@my-project.com} | |
role :db, %w{root@my-project.com} | |
server 'my-project.com', user: 'root', roles: %w{web app} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lock '3.2.1' | |
set :application, 'project_name' | |
set :repo_url, 'git@example.com/repo.git' | |
set :deploy_to, '/var/www/project_name' | |
set :linked_files, %w{.env config/database.yml} | |
set :linked_dirs, %w{bin log tmp/pids tmp/cache public/system} | |
set :rvm_ruby_version, '2.1.2' | |
namespace :deploy do | |
desc 'Restart application' | |
task :restart_unicorn do | |
on roles :app, in: :sequence, wait: 5 do | |
execute 'service unicorn upgrade' | |
end | |
end | |
after :publishing, :restart_unicorn | |
end | |
namespace :setup do | |
desc "Update '/etc/init.d/unicorn' script" | |
task :unicorn do | |
on roles :app do | |
info "Updating '/etc/init.d/unicorn' script" | |
sudo "cp #{release_path}/config/deploy/init.d/unicorn /etc/init.d/unicorn" | |
sudo "chmod a+x /etc/init.d/unicorn" | |
end | |
end | |
end | |
after 'deploy:updated', 'setup:unicorn' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
# ... | |
gem 'capistrano', '~> 3.2.0' | |
gem 'capistrano-bundler', '~> 1.1.2' | |
gem 'capistrano-rails', '~> 1.1' | |
gem 'capistrano-rvm' | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment