Skip to content

Instantly share code, notes, and snippets.

@lucascaton
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucascaton/7eac4b9c374c45f6d986 to your computer and use it in GitHub Desktop.
Save lucascaton/7eac4b9c374c45f6d986 to your computer and use it in GitHub Desktop.
Capistrano v3 configuration example
# ...
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
# 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}
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'
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