Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:04
What would you like to do?
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{}
role :web, %w{}
role :db, %w{}
server '', user: 'root', roles: %w{web app}
lock '3.2.1'
set :application, 'project_name'
set :repo_url, ''
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'
after :publishing, :restart_unicorn
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"
after 'deploy:updated', 'setup:unicorn'
source ''
# ...
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