g5cap 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/.rvmrc +1 -0
- data/Capfile +1 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +61 -0
- data/README +14 -0
- data/Rakefile +12 -0
- data/g5cap.gemspec +28 -0
- data/lib/g5cap.rb +63 -0
- data/lib/version.rb +3 -0
- data/recipes/campfire.rb +41 -0
- data/recipes/newrelic.rb +8 -0
- data/recipes/unicorn.rb +54 -0
- metadata +174 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/*
|
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use --create 1.8.7-p330@g5cap
|
data/Capfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.expand_path('../lib', __FILE__), 'g5cap.rb')
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
g5cap (0.1.0)
|
5
|
+
capistrano (= 2.5.19)
|
6
|
+
eycap (= 0.5.9)
|
7
|
+
newrelic_rpm (= 2.12.1)
|
8
|
+
rake
|
9
|
+
tinder (= 1.4.3)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: http://rubygems.org/
|
13
|
+
remote: http://gems.github.com/
|
14
|
+
remote: http://gems.g5search.com/
|
15
|
+
specs:
|
16
|
+
activesupport (3.0.7)
|
17
|
+
addressable (2.2.5)
|
18
|
+
capistrano (2.5.19)
|
19
|
+
highline
|
20
|
+
net-scp (>= 1.0.0)
|
21
|
+
net-sftp (>= 2.0.0)
|
22
|
+
net-ssh (>= 2.0.14)
|
23
|
+
net-ssh-gateway (>= 1.0.0)
|
24
|
+
eventmachine (0.12.10)
|
25
|
+
eycap (0.5.9)
|
26
|
+
capistrano (>= 2.2.0)
|
27
|
+
faraday (0.5.7)
|
28
|
+
addressable (~> 2.2.4)
|
29
|
+
multipart-post (~> 1.1.0)
|
30
|
+
rack (< 2, >= 1.1.0)
|
31
|
+
highline (1.6.1)
|
32
|
+
mime-types (1.16)
|
33
|
+
multipart-post (1.1.0)
|
34
|
+
net-scp (1.0.4)
|
35
|
+
net-ssh (>= 1.99.1)
|
36
|
+
net-sftp (2.0.5)
|
37
|
+
net-ssh (>= 2.0.9)
|
38
|
+
net-ssh (2.1.4)
|
39
|
+
net-ssh-gateway (1.0.1)
|
40
|
+
net-ssh (>= 1.99.1)
|
41
|
+
newrelic_rpm (2.12.1)
|
42
|
+
rack (1.2.2)
|
43
|
+
rake (0.8.7)
|
44
|
+
simple_oauth (0.1.4)
|
45
|
+
tinder (1.4.3)
|
46
|
+
activesupport
|
47
|
+
eventmachine
|
48
|
+
faraday (~> 0.5.1)
|
49
|
+
mime-types
|
50
|
+
multipart-post
|
51
|
+
twitter-stream
|
52
|
+
twitter-stream (0.1.13)
|
53
|
+
eventmachine (~> 0.12.8)
|
54
|
+
simple_oauth (~> 0.1.4)
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
ruby
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
bundler (>= 1.0.10)
|
61
|
+
g5cap!
|
data/README
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
g5cap - making it easier to reuse our deployment recipes
|
2
|
+
|
3
|
+
Install:
|
4
|
+
gem install g5cap
|
5
|
+
|
6
|
+
Usage:
|
7
|
+
require 'g5cap'
|
8
|
+
cap -T
|
9
|
+
|
10
|
+
Currently, there are recipes for new relic deployment tagging, unicorn, and campfire messaging. See lib/g5cap.rb for more information. If you find a recipe missing or would like to add a new one git clone git@github.com:g5search/g5cap.git, bundle install, and go to town.
|
11
|
+
|
12
|
+
Where the f%*! are the tests?
|
13
|
+
|
14
|
+
Good question. I haven't figured out a super simple way to setup a test environment for these recipes. My only answer atm is to test your changes on staging manually. Tim realizes this sucks and will be working on a solution for this.
|
data/Rakefile
ADDED
data/g5cap.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
3
|
+
require 'version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "g5cap"
|
7
|
+
s.version = G5cap::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['G5']
|
10
|
+
s.homepage = %q{http://github.com/g5search/g5cap}
|
11
|
+
s.summary = "Common cap tasks/recipes"
|
12
|
+
s.description = "Common cap tasks/custom recipes"
|
13
|
+
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
s.add_development_dependency "bundler", ">= 1.0.10"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
|
20
|
+
s.require_path = 'lib'
|
21
|
+
|
22
|
+
#Defaults
|
23
|
+
s.add_runtime_dependency('rake')
|
24
|
+
s.add_runtime_dependency("capistrano", "2.5.19")
|
25
|
+
s.add_runtime_dependency("eycap", "0.5.9")
|
26
|
+
s.add_runtime_dependency("newrelic_rpm", "2.12.1")
|
27
|
+
s.add_runtime_dependency("tinder", "1.4.3")
|
28
|
+
end
|
data/lib/g5cap.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
|
3
|
+
unless Capistrano::Configuration.respond_to?(:instance)
|
4
|
+
abort "G5cap requires Capistrano >= 2."
|
5
|
+
end
|
6
|
+
|
7
|
+
#Load dependencies first
|
8
|
+
require 'rubygems'
|
9
|
+
require 'tinder'
|
10
|
+
require 'new_relic/recipes' #Load recipes
|
11
|
+
|
12
|
+
#Load all of our recipes
|
13
|
+
recipes= File.expand_path(File.join(File.dirname(__FILE__), '..', 'recipes'))
|
14
|
+
require "#{recipes}/unicorn"
|
15
|
+
require "#{recipes}/campfire"
|
16
|
+
require "#{recipes}/campfire"
|
17
|
+
|
18
|
+
Capistrano::Configuration.instance(true).load do
|
19
|
+
# Taken from the capistrano code.
|
20
|
+
def _cset(name, *args, &block)
|
21
|
+
unless exists?(name)
|
22
|
+
set(name, *args, &block)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'Set the branch by splitting the tag unless already set'
|
27
|
+
task :set_branch do
|
28
|
+
unless exists? :branch
|
29
|
+
default_tag = `git tag`.split("\n").last
|
30
|
+
tag = Capistrano::CLI.ui.ask "(Tag|Branch|Commit) to deploy [#{default_tag}]: "
|
31
|
+
tag = default_tag if tag.empty?
|
32
|
+
set( :branch, tag )
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
namespace :deploy do
|
37
|
+
#Using unicorn mainly but could be configured for other webservers:
|
38
|
+
# add a recipe
|
39
|
+
# set app_server and use in place of unicorn namespace ie send(app_server.to_sym).restart
|
40
|
+
desc "Restart the Unicorn processes on the app slices."
|
41
|
+
task :restart, :roles => :app, :except=>{:app_server=>false} do
|
42
|
+
unicorn.deploy
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "Start the Unicorn processes on the app slices."
|
46
|
+
task :start, :roles => :app, :except=>{:app_server=>false} do
|
47
|
+
unicorn.start
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "Stop the Unicorn processes on the app slices."
|
51
|
+
task :stop, :roles => :app, :except=>{:app_server=>false} do
|
52
|
+
unicorn.stop
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
#Default New Relic notices to false as only one of our apps uses this service
|
57
|
+
_cset(:new_relic, false)
|
58
|
+
if new_relic
|
59
|
+
before 'newrelic:notice_deployment', 'newrelic:set_revision'
|
60
|
+
after 'deploy:update', 'newrelic:notice_deployment'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
data/lib/version.rb
ADDED
data/recipes/campfire.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :campfire do
|
3
|
+
desc "Send message to campfire room about deploy lifecycle events"
|
4
|
+
task :notify do
|
5
|
+
[campfire_account, campfire_token, campfire_room].each do |setting|
|
6
|
+
abort("Campfire notifications require 'campfire_token', 'campfire_account', & 'campfire_room' to be set") unless setting
|
7
|
+
end
|
8
|
+
lobby = Tinder::Campfire.new campfire_account, :ssl => true, :token => campfire_token
|
9
|
+
room = lobby.find_room_by_name(campfire_room)
|
10
|
+
room.speak(fetch(:campfire_message))
|
11
|
+
end
|
12
|
+
|
13
|
+
namespace :message do
|
14
|
+
desc "Send a message to campfire room about beginning a deploy"
|
15
|
+
task :start, :except => { :no_campfire => true } do
|
16
|
+
set :campfire_message, "Starting deploy on server #{rails_env} with #{branch}/#{real_revision[0, 7]} to #{deploy_to}"
|
17
|
+
notify
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Send a message to campfire room about completing a deploy"
|
21
|
+
task :finish, :except => { :no_campfire => true } do
|
22
|
+
set :campfire_message, "Finished deploy on server #{rails_env} with #{branch}/#{real_revision[0, 7]} to #{deploy_to}"
|
23
|
+
notify
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "Send a message to campfire room about rollingback a deploy"
|
27
|
+
task :rollback, :except => { :no_campfire => true } do
|
28
|
+
set :campfire_message, "Rolling back deploy on server #{rails_env} from #{latest_revision[0, 7]} to #{previous_revision[0, 7]} to #{deploy_to}"
|
29
|
+
notify
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
_cset(:campfire, true) #Use campfire by default for any environment
|
35
|
+
if campfire
|
36
|
+
before "deploy", "campfire:message:start"
|
37
|
+
after "deploy", "campfire:message:finish"
|
38
|
+
after "deploy:rollback", "campfire:message:rollback"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
data/recipes/newrelic.rb
ADDED
data/recipes/unicorn.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :unicorn do
|
3
|
+
desc <<-DESC
|
4
|
+
Start the Unicorn Master. This uses the :use_sudo variable to determine whether to use sudo or not. By default, :use_sudo is set to true.
|
5
|
+
DESC
|
6
|
+
task :start, :roles => [:app], :except => {:unicorn => false} do
|
7
|
+
sudo "/usr/bin/monit start all -g #{monit_group}"
|
8
|
+
end
|
9
|
+
|
10
|
+
desc <<-DESC
|
11
|
+
Restart the Unicorn processes on the app server by starting and stopping the master. This uses the :use_sudo variable to determine whether to use sudo or not. By default, :use_sudo is set to true.
|
12
|
+
DESC
|
13
|
+
task :restart, :roles => [:app], :except => {:unicorn => false} do
|
14
|
+
sudo "/usr/bin/monit restart all -g #{monit_group}"
|
15
|
+
end
|
16
|
+
|
17
|
+
desc <<-DESC
|
18
|
+
Stop the Unicorn processes on the app server. This uses the :use_sudo
|
19
|
+
variable to determine whether to use sudo or not. By default, :use_sudo is
|
20
|
+
set to true.
|
21
|
+
DESC
|
22
|
+
task :stop, :roles => [:app], :except => {:unicorn => false} do
|
23
|
+
sudo "/usr/bin/monit stop all -g #{monit_group}"
|
24
|
+
end
|
25
|
+
|
26
|
+
desc <<-DESC
|
27
|
+
Reloads the unicorn works gracefully - Use deploy task for deploys
|
28
|
+
DESC
|
29
|
+
task :reload, :roles => [:app], :except => {:unicorn => false} do
|
30
|
+
sudo "/engineyard/bin/unicorn #{application} reload"
|
31
|
+
end
|
32
|
+
|
33
|
+
desc <<-DESC
|
34
|
+
Adds a Unicorn worker - Beware of causing your host to swap, this setting isn't permanent
|
35
|
+
DESC
|
36
|
+
task :aworker, :roles => [:app], :except => {:unicorn => false} do
|
37
|
+
sudo "/engineyard/bin/unicorn #{application} aworker"
|
38
|
+
end
|
39
|
+
|
40
|
+
desc <<-DESC
|
41
|
+
Removes a unicorn worker (gracefully)
|
42
|
+
DESC
|
43
|
+
task :rworker, :roles => [:app], :except => {:unicorn => false} do
|
44
|
+
sudo "/engineyard/bin/unicorn #{application} rworker"
|
45
|
+
end
|
46
|
+
|
47
|
+
desc <<-DESC
|
48
|
+
Deploys app gracefully with USR2 and unicorn.rb combo
|
49
|
+
DESC
|
50
|
+
task :deploy, :roles => [:app], :except => {:unicorn => false} do
|
51
|
+
sudo "/engineyard/bin/unicorn #{application} deploy"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: g5cap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- G5
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-24 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 3
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
- 10
|
32
|
+
version: 1.0.10
|
33
|
+
version_requirements: *id001
|
34
|
+
name: bundler
|
35
|
+
prerelease: false
|
36
|
+
type: :development
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
version_requirements: *id002
|
48
|
+
name: rake
|
49
|
+
prerelease: false
|
50
|
+
type: :runtime
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - "="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 61
|
58
|
+
segments:
|
59
|
+
- 2
|
60
|
+
- 5
|
61
|
+
- 19
|
62
|
+
version: 2.5.19
|
63
|
+
version_requirements: *id003
|
64
|
+
name: capistrano
|
65
|
+
prerelease: false
|
66
|
+
type: :runtime
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - "="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 25
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
- 5
|
77
|
+
- 9
|
78
|
+
version: 0.5.9
|
79
|
+
version_requirements: *id004
|
80
|
+
name: eycap
|
81
|
+
prerelease: false
|
82
|
+
type: :runtime
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - "="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 61
|
90
|
+
segments:
|
91
|
+
- 2
|
92
|
+
- 12
|
93
|
+
- 1
|
94
|
+
version: 2.12.1
|
95
|
+
version_requirements: *id005
|
96
|
+
name: newrelic_rpm
|
97
|
+
prerelease: false
|
98
|
+
type: :runtime
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - "="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
hash: 1
|
106
|
+
segments:
|
107
|
+
- 1
|
108
|
+
- 4
|
109
|
+
- 3
|
110
|
+
version: 1.4.3
|
111
|
+
version_requirements: *id006
|
112
|
+
name: tinder
|
113
|
+
prerelease: false
|
114
|
+
type: :runtime
|
115
|
+
description: Common cap tasks/custom recipes
|
116
|
+
email:
|
117
|
+
executables: []
|
118
|
+
|
119
|
+
extensions: []
|
120
|
+
|
121
|
+
extra_rdoc_files: []
|
122
|
+
|
123
|
+
files:
|
124
|
+
- .gitignore
|
125
|
+
- .rvmrc
|
126
|
+
- Capfile
|
127
|
+
- Gemfile
|
128
|
+
- Gemfile.lock
|
129
|
+
- README
|
130
|
+
- Rakefile
|
131
|
+
- g5cap.gemspec
|
132
|
+
- lib/g5cap.rb
|
133
|
+
- lib/version.rb
|
134
|
+
- recipes/campfire.rb
|
135
|
+
- recipes/newrelic.rb
|
136
|
+
- recipes/unicorn.rb
|
137
|
+
has_rdoc: true
|
138
|
+
homepage: http://github.com/g5search/g5cap
|
139
|
+
licenses: []
|
140
|
+
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
hash: 3
|
152
|
+
segments:
|
153
|
+
- 0
|
154
|
+
version: "0"
|
155
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
|
+
none: false
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
hash: 23
|
161
|
+
segments:
|
162
|
+
- 1
|
163
|
+
- 3
|
164
|
+
- 6
|
165
|
+
version: 1.3.6
|
166
|
+
requirements: []
|
167
|
+
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 1.6.2
|
170
|
+
signing_key:
|
171
|
+
specification_version: 3
|
172
|
+
summary: Common cap tasks/recipes
|
173
|
+
test_files: []
|
174
|
+
|