crapapult 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +102 -1
- data/VERSION +1 -1
- data/lib/crapapult.rb +3 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -1,8 +1,109 @@
|
|
1
1
|
# crapapult
|
2
2
|
|
3
|
+
Crapapult is a thin wrapper around Capistrano for the sole purpose of deploying
|
4
|
+
services at [Yammer](http://www.yammer.com).
|
5
|
+
|
6
|
+
## What the hell is going on here
|
7
|
+
|
8
|
+
At Yammer, we use
|
9
|
+
[Hudson](http://hudson-ci.org/)/[Jenkins](http://jenkins-ci.org/) to build all
|
10
|
+
of our JVM-based services. Each time we commit to the various branches of a
|
11
|
+
service, Hudson runs all the tests and (if they pass, naturally) builds a fat,
|
12
|
+
deployable JAR containing all the various dependencies.
|
13
|
+
|
14
|
+
Crapapult allows us to deploy new versions of our services *and* synchronize
|
15
|
+
those deploys with changes to application-specific configuration. (We use
|
16
|
+
Puppet to provision and maintain machines with broad roles but use Crapapult to
|
17
|
+
generate all the application-specific configuration.)
|
18
|
+
|
19
|
+
It does so by using Capistrano to SSH into each of the application servers and
|
20
|
+
using `curl` to download the last successful build artifact from the specified
|
21
|
+
Hudson job. This tends to be super-fast, especially if your CI box is located in
|
22
|
+
the same data center as your app servers.
|
23
|
+
|
24
|
+
Once the artifact is staged (by default in `/opt/APPNAME`), it then uploads the
|
25
|
+
specified set of asset files to each server. After that, it renders and uploads
|
26
|
+
the specified set of template files to each server.
|
27
|
+
|
28
|
+
Then it restarts your service and gives you a high-five.
|
29
|
+
|
30
|
+
## How to use this dang thing
|
31
|
+
|
32
|
+
Get yer install on:
|
33
|
+
|
3
34
|
gem install crapapult
|
4
35
|
|
5
|
-
|
36
|
+
Create yer dang deployer directory structure:
|
37
|
+
|
38
|
+
mkdir -p myapp-crapapult/{assets,templates}
|
39
|
+
cd myapp-crapapult
|
40
|
+
|
41
|
+
And start slingin' some crap in your `Capfile`:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require "crapapult"
|
45
|
+
|
46
|
+
# Give your application a name.
|
47
|
+
application "myapp" do
|
48
|
+
# Upload the file in assets/myapp.jvm.conf to each host.
|
49
|
+
asset "myapp.jvm.conf", "/etc/myapp.jvm.conf"
|
50
|
+
|
51
|
+
# Render the ERB template in templates/myapp.conf.erb to each host.
|
52
|
+
template "myapp.conf.erb", "/etc/myapp.conf", :mode => "0600"
|
53
|
+
|
54
|
+
# Set up the file in assets/myapp.upstart as an Upstart config file and create
|
55
|
+
# an /etc/init.d/myapp script.
|
56
|
+
upstart "myapp.upstart"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Specify where your Hudson/Jenkins server is.
|
60
|
+
hudson "http://build.example.com"
|
61
|
+
|
62
|
+
# Specify the various branches and their respective build jobs.
|
63
|
+
branch :master, "myapp-release"
|
64
|
+
branch :development, "myapp-development"
|
65
|
+
|
66
|
+
# Define environments with allowed branches.
|
67
|
+
environment :staging, [:master, :development] do
|
68
|
+
# Set environment-specific data for your templates to work with.
|
69
|
+
data :jdbc_url, "jdbc:postgresql://db.example.com/happy_fun_times"
|
70
|
+
|
71
|
+
host "myapp-001.staging.example.com" do
|
72
|
+
# Set host-specific data for your templates to work with.
|
73
|
+
data :worker_id, "1"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# This will disallow deploying the staging branch to production.
|
78
|
+
environment :production, [:master] do
|
79
|
+
# Set environment-specific data for your templates to work with.
|
80
|
+
data :jdbc_url, "jdbc:postgresql://db.example.com/happy_fun_times"
|
81
|
+
|
82
|
+
host "myapp-001.example.com" do
|
83
|
+
# Set host-specific data for your templates to work with.
|
84
|
+
data :worker_id, "1"
|
85
|
+
end
|
86
|
+
|
87
|
+
host "myapp-002.example.com" do
|
88
|
+
data :worker_id, "2"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
```
|
92
|
+
|
93
|
+
## Deploying a thing
|
94
|
+
|
95
|
+
cap deploy # Deploy the specified branch to the specified environment
|
96
|
+
cap from:development # Deploy the development branch
|
97
|
+
cap from:master # Deploy the master branch
|
98
|
+
cap to:production # Deploy to the production environment
|
99
|
+
cap to:staging # Deploy to the staging environment
|
100
|
+
|
101
|
+
So to deploy your development branch to your staging environment, it's just a
|
102
|
+
simple:
|
103
|
+
|
104
|
+
cap from:development to:staging deploy
|
105
|
+
|
106
|
+
And you're off to the races.
|
6
107
|
|
7
108
|
--------------------------------------------------------------------------------
|
8
109
|
Copyright (c) 2011 Yammer, Inc. See LICENSE.txt for further details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/lib/crapapult.rb
CHANGED
@@ -81,6 +81,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
81
81
|
set :owner_group, group
|
82
82
|
namespace :deploy do
|
83
83
|
task :configure do
|
84
|
+
setup
|
84
85
|
puts "> Configuring the application"
|
85
86
|
app_block.call
|
86
87
|
end
|
@@ -180,6 +181,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
180
181
|
end
|
181
182
|
|
182
183
|
task :stage, :role => :app do
|
184
|
+
setup
|
183
185
|
puts "> Downloading the artifact remotely"
|
184
186
|
run "curl --silent #{artifact_url} --output #{temp_dir}/#{artifact_filename}"
|
185
187
|
run "#{sudo} cp #{temp_dir}/#{artifact_filename} #{directory}/#{artifact_filename}"
|
@@ -192,6 +194,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
192
194
|
end
|
193
195
|
|
194
196
|
task :cleanup, :role => :app do
|
197
|
+
setup
|
195
198
|
puts "> Cleaning up"
|
196
199
|
run "rm -rf #{temp_dir}"
|
197
200
|
end
|
@@ -199,7 +202,6 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
199
202
|
task :restart, :role => :app, :max_hosts => 1 do
|
200
203
|
puts "> Stopping #{application_name}"
|
201
204
|
run "#{sudo} stop #{application_name} || true"
|
202
|
-
run "sleep 10"
|
203
205
|
puts "> Starting #{application_name}"
|
204
206
|
run "#{sudo} start #{application_name}"
|
205
207
|
run "sleep 10"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crapapult
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Coda Hale
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-20 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|