2013-02-08 15:18:51 +00:00
|
|
|
# Capistrano [](https://travis-ci.org/capistrano/capistrano)
|
2013-02-01 09:19:14 +00:00
|
|
|
|
2013-04-28 19:00:52 +01:00
|
|
|
TODO
|
2013-02-01 09:19:14 +00:00
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
Add this line to your application's Gemfile:
|
|
|
|
|
2013-03-22 16:34:31 +00:00
|
|
|
gem 'capistrano', github: 'capistrano/capistrano', branch: :v3
|
2013-02-01 09:19:14 +00:00
|
|
|
|
|
|
|
And then execute:
|
|
|
|
|
2013-02-08 11:15:27 +00:00
|
|
|
$ bundle --binstubs
|
2013-02-01 09:19:14 +00:00
|
|
|
|
2013-02-01 14:41:51 +00:00
|
|
|
Capify:
|
|
|
|
|
2013-02-08 11:15:27 +00:00
|
|
|
$ cap install
|
|
|
|
|
|
|
|
This creates the following files:
|
|
|
|
|
|
|
|
- `Capfile`
|
|
|
|
- `lib/deploy/tasks`
|
|
|
|
- `config/deploy/staging.rb`
|
|
|
|
- `config/deploy/production.rb`
|
|
|
|
|
|
|
|
To create different stages:
|
|
|
|
|
|
|
|
$ cap install STAGES=local,sandbox,qa,production
|
2013-02-01 09:19:14 +00:00
|
|
|
|
2013-02-01 14:41:51 +00:00
|
|
|
## Usage
|
2013-02-01 09:19:14 +00:00
|
|
|
|
2013-02-01 14:41:51 +00:00
|
|
|
$ cap -vT
|
2013-02-01 09:19:14 +00:00
|
|
|
|
2013-02-08 11:15:27 +00:00
|
|
|
$ cap staging deploy
|
|
|
|
$ cap production deploy
|
|
|
|
|
2013-02-10 17:59:06 +00:00
|
|
|
$ cap production deploy --dry-run
|
|
|
|
$ cap production deploy --prereqs
|
2013-05-24 11:01:29 +01:00
|
|
|
$ cap production deploy --trace
|
2013-02-10 17:59:06 +00:00
|
|
|
|
2013-03-10 20:43:39 +00:00
|
|
|
## Configuration
|
|
|
|
|
|
|
|
# config/deploy.rb
|
|
|
|
set :application, 'example app'
|
|
|
|
|
|
|
|
# config/deploy/production.rb
|
|
|
|
set :stage, :production
|
2013-03-15 11:35:49 +00:00
|
|
|
|
|
|
|
ask :branch, :master
|
|
|
|
|
2013-03-22 16:29:11 +00:00
|
|
|
role :app, %w{example.com example2.com}
|
2013-03-10 20:43:39 +00:00
|
|
|
role :web, %w{example.com}
|
|
|
|
role :db, %w{example.com}
|
|
|
|
|
2013-03-22 16:29:11 +00:00
|
|
|
# the first server in the array is considered primary
|
|
|
|
|
2013-02-08 11:15:27 +00:00
|
|
|
## Tasks
|
2013-02-08 09:15:10 +00:00
|
|
|
|
|
|
|
## Before / After
|
|
|
|
|
|
|
|
Where calling on the same task name, executed in order of inclusion
|
|
|
|
|
|
|
|
|
|
|
|
# call an existing task
|
|
|
|
before :starting, :ensure_user
|
|
|
|
|
|
|
|
after :finishing, :notify
|
|
|
|
|
|
|
|
|
|
|
|
# or define in block
|
|
|
|
before :starting, :ensure_user do
|
|
|
|
#
|
|
|
|
end
|
|
|
|
|
|
|
|
after :finishing, :notify do
|
|
|
|
#
|
|
|
|
end
|
|
|
|
|
2013-03-08 15:55:29 +00:00
|
|
|
## Console
|
|
|
|
|
2013-03-15 14:19:00 +00:00
|
|
|
Execute arbitrary remote commands
|
2013-03-08 15:55:29 +00:00
|
|
|
|
|
|
|
$ cap staging console
|
|
|
|
|
2013-02-08 11:15:27 +00:00
|
|
|
## Configuration
|
2013-02-08 09:15:10 +00:00
|
|
|
|
|
|
|
|
2013-02-08 11:15:27 +00:00
|
|
|
## SSHKit
|
2013-02-08 09:15:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|