2013-02-08 15:18:51 +00:00
|
|
|
# Capistrano [![Build Status](https://travis-ci.org/capistrano/capistrano.png?branch=v3)](https://travis-ci.org/capistrano/capistrano)
|
2013-02-01 09:19:14 +00:00
|
|
|
|
2013-06-07 17:45:39 +02:00
|
|
|
## Requirements
|
|
|
|
|
|
|
|
Ruby 2.0
|
|
|
|
|
2013-02-01 09:19:14 +00:00
|
|
|
## Installation
|
|
|
|
|
|
|
|
Add this line to your application's Gemfile:
|
|
|
|
|
2013-05-28 19:00:13 +02:00
|
|
|
``` ruby
|
|
|
|
gem 'capistrano', github: 'capistrano/capistrano', branch: :v3
|
|
|
|
```
|
2013-02-01 09:19:14 +00:00
|
|
|
|
|
|
|
And then execute:
|
|
|
|
|
2013-05-28 19:00:13 +02:00
|
|
|
``` ruby
|
|
|
|
$ bundle --binstubs
|
|
|
|
```
|
2013-02-01 09:19:14 +00:00
|
|
|
|
2013-02-01 14:41:51 +00:00
|
|
|
Capify:
|
|
|
|
|
2013-05-28 19:00:13 +02:00
|
|
|
``` shell
|
|
|
|
$ cap install
|
|
|
|
```
|
2013-02-08 11:15:27 +00:00
|
|
|
|
|
|
|
This creates the following files:
|
|
|
|
|
2013-05-28 19:00:13 +02:00
|
|
|
```
|
|
|
|
├── Capfile
|
|
|
|
├── config
|
|
|
|
│ ├── deploy
|
|
|
|
│ │ ├── production.rb
|
|
|
|
│ │ └── staging.rb
|
|
|
|
│ └── deploy.rb
|
|
|
|
└── lib
|
|
|
|
└── capistrano
|
|
|
|
└── tasks
|
|
|
|
```
|
2013-02-08 11:15:27 +00:00
|
|
|
|
|
|
|
To create different stages:
|
|
|
|
|
2013-05-28 19:00:13 +02:00
|
|
|
``` shell
|
|
|
|
$ 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-05-28 19:00:13 +02:00
|
|
|
``` shell
|
|
|
|
$ cap -vT
|
2013-03-10 20:43:39 +00:00
|
|
|
|
2013-05-28 19:00:13 +02:00
|
|
|
$ cap staging deploy
|
|
|
|
$ cap production deploy
|
2013-03-15 11:35:49 +00:00
|
|
|
|
2013-05-28 19:00:13 +02:00
|
|
|
$ cap production deploy --dry-run
|
|
|
|
$ cap production deploy --prereqs
|
|
|
|
$ cap production deploy --trace
|
|
|
|
```
|
2013-03-15 11:35:49 +00:00
|
|
|
|
2013-05-28 19:00:13 +02:00
|
|
|
## Tasks
|
2013-03-10 20:43:39 +00:00
|
|
|
|
2013-03-22 16:29:11 +00:00
|
|
|
|
2013-02-08 09:15:10 +00:00
|
|
|
|
|
|
|
## Before / After
|
|
|
|
|
|
|
|
Where calling on the same task name, executed in order of inclusion
|
|
|
|
|
2013-05-28 19:00:13 +02:00
|
|
|
``` ruby
|
|
|
|
# call an existing task
|
|
|
|
before :starting, :ensure_user
|
2013-02-08 09:15:10 +00:00
|
|
|
|
2013-05-28 19:00:13 +02:00
|
|
|
after :finishing, :notify
|
2013-02-08 09:15:10 +00:00
|
|
|
|
|
|
|
|
2013-05-28 19:00:13 +02:00
|
|
|
# or define in block
|
|
|
|
before :starting, :ensure_user do
|
|
|
|
#
|
|
|
|
end
|
2013-02-08 09:15:10 +00:00
|
|
|
|
2013-05-28 19:00:13 +02:00
|
|
|
after :finishing, :notify do
|
|
|
|
#
|
|
|
|
end
|
|
|
|
```
|
2013-02-08 09:15:10 +00:00
|
|
|
|
2013-03-08 15:55:29 +00:00
|
|
|
## Console
|
|
|
|
|
2013-05-28 19:00:13 +02:00
|
|
|
Execute arbitrary remote commands, to use this simply add
|
|
|
|
`require 'capistrano/console'` which will add the necessary tasks to your
|
|
|
|
environment:
|
2013-03-08 15:55:29 +00:00
|
|
|
|
2013-05-28 19:00:13 +02:00
|
|
|
``` shell
|
|
|
|
$ cap staging console
|
|
|
|
```
|
2013-03-08 15:55:29 +00:00
|
|
|
|
2013-02-08 11:15:27 +00:00
|
|
|
## Configuration
|
2013-02-08 09:15:10 +00:00
|
|
|
|
|
|
|
|
2013-06-07 17:45:39 +02:00
|
|
|
## SSHKit
|