capistrano-relevance 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +152 -0
- data/Rakefile +1 -0
- data/capistrano-relevance.gemspec +22 -0
- data/lib/capistrano/relevance.rb +1 -0
- data/lib/capistrano/relevance/all.rb +4 -0
- data/lib/capistrano/relevance/base.rb +3 -0
- data/lib/capistrano/relevance/common.rb +12 -0
- data/lib/capistrano/relevance/migrate_after_update_code.rb +5 -0
- data/lib/capistrano/relevance/passenger.rb +11 -0
- data/lib/capistrano/relevance/symlink_configs.rb +16 -0
- data/lib/capistrano/relevance/version.rb +5 -0
- metadata +76 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Relevance
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
# Capistrano::Relevance
|
2
|
+
|
3
|
+
A collection of commonly-used (default) Capistrano recipes for Rails projects at [Relevance](http://thinkrelevance.com).
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add these lines to the Gemfile in your Rails application:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
group :deployment do
|
12
|
+
gem 'capistrano', :git => 'git://github.com/capistrano/capistrano', :ref => 'b31e2f5'
|
13
|
+
gem 'capistrano-relevance'
|
14
|
+
end
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
```sh
|
20
|
+
bundle
|
21
|
+
```
|
22
|
+
|
23
|
+
**Note**: You will notice that we rely on a specific revision of Capistrano in the `Gemfile` above. (Weird, right?)
|
24
|
+
At the time of this writing, Capistrano 2.13.4 is the latest *released* version;
|
25
|
+
however, 2.13.4 hardcoded the SCM to `:subversion`, which caused a problem for `capistrano-relevance`.
|
26
|
+
[Pull request 223](https://github.com/capistrano/capistrano/pull/233) addresses this issue.
|
27
|
+
`b31e2f5` is the last commit from that pull request, so `capistrano-relevance` needs to depend on that commit until a new version of Capistrano is released (e.g., 2.13.4.1 or 2.13.5).
|
28
|
+
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
After installing `capistrano-relevance` as described above, you are ready to set up your Capistrano deployment. First, you need to `capify` your app:
|
33
|
+
|
34
|
+
bundle exec capify .
|
35
|
+
|
36
|
+
From here, there are two ways that you can use `capistrano-relevance`:
|
37
|
+
|
38
|
+
1. Use the [default set of recipes](https://github.com/relevance/capistrano-relevance/blob/master/lib/capistrano/relevance/all.rb), or
|
39
|
+
2. Use a customized set of recipes.
|
40
|
+
|
41
|
+
We'll first walk through the process for using the default set of recipes.
|
42
|
+
From there, it's easy for you pick and choose a different set of recipes.
|
43
|
+
|
44
|
+
|
45
|
+
### Using the default set of recipes
|
46
|
+
|
47
|
+
#### Configuring deploy.rb
|
48
|
+
|
49
|
+
To use the `capistrano-relevance` recipes, you will edit your `config/deploy.rb` file to require the `capistrano-relevance` recipes.
|
50
|
+
You will also define a few additional required settings.
|
51
|
+
|
52
|
+
Here is an example file that is ready for use with `capistrano-relevance`:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
require 'bundler/capistrano'
|
56
|
+
require 'capistrano/relevance/all'
|
57
|
+
|
58
|
+
set :application, "your_app_name"
|
59
|
+
set :repository, "git://github.com/username/your_app_name"
|
60
|
+
|
61
|
+
role :web, "your_app_name.example.com"
|
62
|
+
role :app, "your_app_name.example.com"
|
63
|
+
role :db, "your_app_name.example.com", :primary => true
|
64
|
+
```
|
65
|
+
|
66
|
+
#### Noteworthy Assumptions
|
67
|
+
|
68
|
+
By default, `capistrano-relevance` [expects](https://github.com/relevance/capistrano-relevance/blob/master/lib/capistrano/relevance/common.rb) to deploy as the following user in the following location:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
set :user, 'deploy'
|
72
|
+
set(:deploy_to) { "/var/www/apps/#{application}" }
|
73
|
+
```
|
74
|
+
|
75
|
+
If your server uses a different user, or deploys in a different location, you can override these settings. For example:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
require 'bundler/capistrano'
|
79
|
+
require 'capistrano/relevance/all'
|
80
|
+
|
81
|
+
set :user, 'apptastic'
|
82
|
+
set(:deploy_to) { "/home/apptastic/apps/#{application}" }
|
83
|
+
|
84
|
+
# other settings here ...
|
85
|
+
```
|
86
|
+
|
87
|
+
#### Deploying
|
88
|
+
|
89
|
+
Now you're ready to start deploying your app to your server.
|
90
|
+
You need to create the directory structure that Capistrano expects and place your database configuration on the server.
|
91
|
+
Best practices (TM) discourage you from checking in any database credentials into your Git repo.
|
92
|
+
Instead, you can create a `database.yml` file on your target server.
|
93
|
+
|
94
|
+
```sh
|
95
|
+
bundle exec cap deploy:setup
|
96
|
+
|
97
|
+
ssh deploy@your_app_name.example.com
|
98
|
+
|
99
|
+
# Create the the directory where you will store your shared configuration.
|
100
|
+
# If you are using a custom :deploy_to value, you should customize this command accordingly.
|
101
|
+
mkdir /var/www/apps/[YOUR-APP-NAME]/shared/config
|
102
|
+
|
103
|
+
# Add production settings for your database
|
104
|
+
vim /var/www/apps/[YOUR-APP-NAME]/shared/config/database.yml
|
105
|
+
|
106
|
+
# We're done messing around on the server; let's get outta here
|
107
|
+
exit
|
108
|
+
```
|
109
|
+
|
110
|
+
Now it's time to deploy your Rails app to the server.
|
111
|
+
Since this is the first time you've deployed this app to the server, you'll need to run a special Capistrano command that does slightly more work than a bare deploy.
|
112
|
+
|
113
|
+
```sh
|
114
|
+
bundle exec cap deploy:cold
|
115
|
+
```
|
116
|
+
|
117
|
+
Congratulations! You should be able to visit `your_app_name.example.com` using your favorite browser and see the application up and running.
|
118
|
+
|
119
|
+
For subsequent deploys, you can simply run:
|
120
|
+
|
121
|
+
```sh
|
122
|
+
bundle exec cap deploy
|
123
|
+
```
|
124
|
+
|
125
|
+
## Use a customized set of recipes
|
126
|
+
|
127
|
+
When you require `capistrano/relevance/all` in your `deploy.rb` file, it includes the [default set of recipes](https://github.com/relevance/capistrano-relevance/blob/master/lib/capistrano/relevance/all.rb).
|
128
|
+
If you need something other than the default set of recipes, you can include a customized set of recipes for your app.
|
129
|
+
To do so, edit your `deploy.rb` file, and replace this line ...
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
require 'capistrano/relevance/all'
|
133
|
+
```
|
134
|
+
|
135
|
+
... with the specific set of recipes you want to use in your app.
|
136
|
+
|
137
|
+
For example, imagine that you're using Unicorn instead of Passenger. You might want to include all recipes *except* the Passenger recipe.
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
require 'capistrano/relevance/common'
|
141
|
+
require 'capistrano/relevance/migrate_after_update_code'
|
142
|
+
require 'capistrano/relevance/symlink_configs'
|
143
|
+
```
|
144
|
+
|
145
|
+
|
146
|
+
## Contributing
|
147
|
+
|
148
|
+
1. Fork it
|
149
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
150
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
151
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
152
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano/relevance/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "capistrano-relevance"
|
8
|
+
gem.version = Capistrano::Relevance::VERSION
|
9
|
+
gem.authors = ["Yoko Harada and Jason Rudolph"]
|
10
|
+
gem.email = ["opensource@thinkrelevance.com"]
|
11
|
+
gem.description = %q{A collection of default Capistrano recipes commonly used on Relevance projects}
|
12
|
+
gem.summary = %q{Relevance recipes for Capistrano}
|
13
|
+
gem.homepage = "https://github.com/relevance/capistrano-relevance"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
# You actually need an unreleased version of Capistrano (2.13.4.1? or 2.13.5?). See README.
|
21
|
+
gem.add_runtime_dependency "capistrano", "~> 2.13.4"
|
22
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "capistrano/relevance/version"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'capistrano/relevance/base'
|
2
|
+
|
3
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
4
|
+
set :user, 'deploy'
|
5
|
+
set :use_sudo, false
|
6
|
+
|
7
|
+
set :scm, :git
|
8
|
+
set :deploy_via, :copy
|
9
|
+
set(:deploy_to) { "/var/www/apps/#{application}" }
|
10
|
+
|
11
|
+
default_run_options[:pty] = true # needed for Git password prompts
|
12
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'capistrano/relevance/base'
|
2
|
+
|
3
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
4
|
+
namespace :deploy do
|
5
|
+
task :start do ; end
|
6
|
+
task :stop do ; end
|
7
|
+
task :restart, :roles => :app, :except => {:no_release => true} do
|
8
|
+
run "#{try_sudo} touch #{File.join(current_path, 'tmp', 'restart.txt')}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'capistrano/relevance/base'
|
2
|
+
|
3
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
4
|
+
# TODO As part of 'deploy:setup', automatically create "#{shared_path}/config"
|
5
|
+
# TODO As part of before 'deploy:symlink_configs', copy database.example.yml if database.yml does not exist
|
6
|
+
|
7
|
+
after 'deploy:finalize_update', 'deploy:symlink_configs'
|
8
|
+
|
9
|
+
namespace :deploy do
|
10
|
+
task :symlink_configs do
|
11
|
+
shared_configs = File.join(shared_path,'config')
|
12
|
+
release_configs = File.join(release_path,'config')
|
13
|
+
run("ln -nfs #{shared_configs}/database.yml #{release_configs}/database.yml")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-relevance
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yoko Harada and Jason Rudolph
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.13.4
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.13.4
|
30
|
+
description: A collection of default Capistrano recipes commonly used on Relevance
|
31
|
+
projects
|
32
|
+
email:
|
33
|
+
- opensource@thinkrelevance.com
|
34
|
+
executables: []
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- .gitignore
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE.txt
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- capistrano-relevance.gemspec
|
44
|
+
- lib/capistrano/relevance.rb
|
45
|
+
- lib/capistrano/relevance/all.rb
|
46
|
+
- lib/capistrano/relevance/base.rb
|
47
|
+
- lib/capistrano/relevance/common.rb
|
48
|
+
- lib/capistrano/relevance/migrate_after_update_code.rb
|
49
|
+
- lib/capistrano/relevance/passenger.rb
|
50
|
+
- lib/capistrano/relevance/symlink_configs.rb
|
51
|
+
- lib/capistrano/relevance/version.rb
|
52
|
+
homepage: https://github.com/relevance/capistrano-relevance
|
53
|
+
licenses: []
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 1.8.24
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Relevance recipes for Capistrano
|
76
|
+
test_files: []
|