recap 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/README.md +55 -10
- data/Rakefile +19 -5
- data/bin/recap +2 -2
- data/features/managing-processes.feature +1 -1
- data/features/setting-environment-variables.feature +26 -1
- data/features/steps/capistrano_steps.rb +10 -6
- data/features/support/project.rb +24 -5
- data/features/templates/project/Capfile.erb +1 -1
- data/lib/recap/recipes/rails.rb +6 -0
- data/lib/recap/recipes/ruby.rb +11 -0
- data/lib/recap/recipes/static.rb +3 -0
- data/lib/recap/recipes.rb +18 -0
- data/lib/recap/support/capistrano_extensions.rb +85 -0
- data/lib/recap/support/cli.rb +57 -0
- data/lib/recap/{compatibility.rb → support/compatibility.rb} +2 -2
- data/lib/recap/support/environment.rb +61 -0
- data/lib/recap/support/namespace.rb +47 -0
- data/lib/recap/support/shell_command.rb +35 -0
- data/lib/recap/support/templates/Capfile.erb +6 -0
- data/lib/recap/tasks/bootstrap.rb +77 -0
- data/lib/recap/{bundler.rb → tasks/bundler.rb} +15 -6
- data/lib/recap/{deploy.rb → tasks/deploy.rb} +30 -17
- data/lib/recap/tasks/env.rb +111 -0
- data/lib/recap/{foreman.rb → tasks/foreman.rb} +20 -12
- data/lib/recap/{preflight.rb → tasks/preflight.rb} +13 -11
- data/lib/recap/tasks/rails.rb +42 -0
- data/lib/recap/tasks.rb +16 -0
- data/lib/recap/version.rb +1 -1
- data/lib/recap.rb +119 -10
- data/recap.gemspec +3 -2
- data/spec/models/capistrano_extensions_spec.rb +41 -0
- data/spec/models/cli_spec.rb +25 -0
- data/spec/models/environment_spec.rb +14 -14
- data/spec/models/shell_command_spec.rb +55 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/tasks/bootstrap_spec.rb +9 -13
- data/spec/tasks/bundler_spec.rb +39 -7
- data/spec/tasks/deploy_spec.rb +42 -26
- data/spec/tasks/env_spec.rb +81 -5
- data/spec/tasks/foreman_spec.rb +10 -5
- data/spec/tasks/rails_spec.rb +80 -0
- metadata +65 -57
- data/doc/index.html +0 -235
- data/doc/lib/recap/bootstrap.html +0 -42
- data/doc/lib/recap/bundler.html +0 -168
- data/doc/lib/recap/capistrano_extensions.html +0 -208
- data/doc/lib/recap/cli.html +0 -42
- data/doc/lib/recap/compatibility.html +0 -73
- data/doc/lib/recap/deploy.html +0 -328
- data/doc/lib/recap/env.html +0 -108
- data/doc/lib/recap/foreman.html +0 -42
- data/doc/lib/recap/namespace.html +0 -42
- data/doc/lib/recap/preflight.html +0 -163
- data/doc/lib/recap/rails.html +0 -42
- data/doc/lib/recap/version.html +0 -42
- data/doc/lib/recap.html +0 -42
- data/index.rb +0 -62
- data/lib/recap/bootstrap.rb +0 -47
- data/lib/recap/capistrano_extensions.rb +0 -74
- data/lib/recap/cli.rb +0 -32
- data/lib/recap/deploy/templates/Capfile.erb +0 -6
- data/lib/recap/env.rb +0 -58
- data/lib/recap/environment.rb +0 -54
- data/lib/recap/namespace.rb +0 -37
- data/lib/recap/rails.rb +0 -24
- data/lib/recap/ruby.rb +0 -3
- data/lib/recap/static.rb +0 -1
data/doc/lib/recap/deploy.html
DELETED
@@ -1,328 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
-
<title>deploy.rb</title>
|
6
|
-
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<div id='container'>
|
10
|
-
<div id="background"></div>
|
11
|
-
<div id="jump_to">
|
12
|
-
Jump To …
|
13
|
-
<div id="jump_wrapper">
|
14
|
-
<div id="jump_page">
|
15
|
-
<a class="source" href="../../index.html">index.rb</a>
|
16
|
-
<a class="source" href="../recap.html">recap.rb</a>
|
17
|
-
<a class="source" href="bootstrap.html">bootstrap.rb</a>
|
18
|
-
<a class="source" href="bundler.html">bundler.rb</a>
|
19
|
-
<a class="source" href="capistrano_extensions.html">capistrano_extensions.rb</a>
|
20
|
-
<a class="source" href="cli.html">cli.rb</a>
|
21
|
-
<a class="source" href="compatibility.html">compatibility.rb</a>
|
22
|
-
<a class="source" href="deploy.html">deploy.rb</a>
|
23
|
-
<a class="source" href="env.html">env.rb</a>
|
24
|
-
<a class="source" href="foreman.html">foreman.rb</a>
|
25
|
-
<a class="source" href="namespace.html">namespace.rb</a>
|
26
|
-
<a class="source" href="preflight.html">preflight.rb</a>
|
27
|
-
<a class="source" href="rails.html">rails.rb</a>
|
28
|
-
<a class="source" href="version.html">version.rb</a>
|
29
|
-
</div>
|
30
|
-
</div>
|
31
|
-
</div>
|
32
|
-
<table cellspacing=0 cellpadding=0>
|
33
|
-
<thead>
|
34
|
-
<tr>
|
35
|
-
<th class=docs><h1>deploy.rb</h1></th>
|
36
|
-
<th class=code></th>
|
37
|
-
</tr>
|
38
|
-
</thead>
|
39
|
-
<tbody>
|
40
|
-
<tr id='section-1'>
|
41
|
-
<td class=docs>
|
42
|
-
<div class="pilwrap">
|
43
|
-
<a class="pilcrow" href="#section-1">¶</a>
|
44
|
-
</div>
|
45
|
-
|
46
|
-
</td>
|
47
|
-
<td class=code>
|
48
|
-
<div class='highlight'><pre><span class="nb">require</span> <span class="s1">'recap'</span>
|
49
|
-
<span class="nb">require</span> <span class="s1">'recap/capistrano_extensions'</span>
|
50
|
-
|
51
|
-
<span class="nb">require</span> <span class="s1">'recap/bootstrap'</span>
|
52
|
-
<span class="nb">require</span> <span class="s1">'recap/bundler'</span>
|
53
|
-
<span class="nb">require</span> <span class="s1">'recap/env'</span>
|
54
|
-
<span class="nb">require</span> <span class="s1">'recap/preflight'</span>
|
55
|
-
|
56
|
-
<span class="k">module</span> <span class="nn">Recap::Deploy</span>
|
57
|
-
<span class="kp">extend</span> <span class="no">Recap</span><span class="o">::</span><span class="no">Namespace</span>
|
58
|
-
|
59
|
-
<span class="n">namespace</span> <span class="ss">:deploy</span> <span class="k">do</span></pre></div>
|
60
|
-
</td>
|
61
|
-
</tr>
|
62
|
-
<tr id='section-2'>
|
63
|
-
<td class=docs>
|
64
|
-
<div class="pilwrap">
|
65
|
-
<a class="pilcrow" href="#section-2">¶</a>
|
66
|
-
</div>
|
67
|
-
<p>To use this recipe, both the application’s name and its git repository are required.</p>
|
68
|
-
</td>
|
69
|
-
<td class=code>
|
70
|
-
<div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:application</span><span class="p">)</span> <span class="p">{</span> <span class="nb">abort</span> <span class="s2">"You must set the name of your application in your Capfile, e.g.: set :application, 'tomafro.net'"</span> <span class="p">}</span>
|
71
|
-
<span class="n">set</span><span class="p">(</span><span class="ss">:repository</span><span class="p">)</span> <span class="p">{</span> <span class="nb">abort</span> <span class="s2">"You must set the git respository location in your Capfile, e.g.: set :respository, 'git@github.com/tomafro/tomafro.net'"</span><span class="p">}</span></pre></div>
|
72
|
-
</td>
|
73
|
-
</tr>
|
74
|
-
<tr id='section-3'>
|
75
|
-
<td class=docs>
|
76
|
-
<div class="pilwrap">
|
77
|
-
<a class="pilcrow" href="#section-3">¶</a>
|
78
|
-
</div>
|
79
|
-
<p>The recipe assumes that the application code will be run as a dedicated user. Any any user who
|
80
|
-
can deploy the application should be added as a member of the application’s group. By default,
|
81
|
-
both the application user and group take the same name as the application.</p>
|
82
|
-
</td>
|
83
|
-
<td class=code>
|
84
|
-
<div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:application_user</span><span class="p">)</span> <span class="p">{</span> <span class="n">application</span> <span class="p">}</span>
|
85
|
-
<span class="n">set</span><span class="p">(</span><span class="ss">:application_group</span><span class="p">)</span> <span class="p">{</span> <span class="n">application_user</span> <span class="p">}</span></pre></div>
|
86
|
-
</td>
|
87
|
-
</tr>
|
88
|
-
<tr id='section-4'>
|
89
|
-
<td class=docs>
|
90
|
-
<div class="pilwrap">
|
91
|
-
<a class="pilcrow" href="#section-4">¶</a>
|
92
|
-
</div>
|
93
|
-
<p>Deployments can be made from any branch. <code>master</code> is used by default.</p>
|
94
|
-
</td>
|
95
|
-
<td class=code>
|
96
|
-
<div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:branch</span><span class="p">,</span> <span class="s1">'master'</span><span class="p">)</span></pre></div>
|
97
|
-
</td>
|
98
|
-
</tr>
|
99
|
-
<tr id='section-5'>
|
100
|
-
<td class=docs>
|
101
|
-
<div class="pilwrap">
|
102
|
-
<a class="pilcrow" href="#section-5">¶</a>
|
103
|
-
</div>
|
104
|
-
<p>Unlike a standard capistrano deployment, all releases are stored directly in the <code>deploy_to</code>
|
105
|
-
directory. The default is <code>/home/#{application_user}/apps/#{application}</code>.</p>
|
106
|
-
</td>
|
107
|
-
<td class=code>
|
108
|
-
<div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:deploy_to</span><span class="p">)</span> <span class="p">{</span> <span class="s2">"/home/</span><span class="si">#{</span><span class="n">application_user</span><span class="si">}</span><span class="s2">/apps/</span><span class="si">#{</span><span class="n">application</span><span class="si">}</span><span class="s2">"</span> <span class="p">}</span></pre></div>
|
109
|
-
</td>
|
110
|
-
</tr>
|
111
|
-
<tr id='section-6'>
|
112
|
-
<td class=docs>
|
113
|
-
<div class="pilwrap">
|
114
|
-
<a class="pilcrow" href="#section-6">¶</a>
|
115
|
-
</div>
|
116
|
-
<p>Each release is marked by a unique tag, generated with the current timestamp. While this can be
|
117
|
-
changed, it’s not recommended, as the sort order of the tag names is important; later tags must
|
118
|
-
be listed after earlier tags.</p>
|
119
|
-
</td>
|
120
|
-
<td class=code>
|
121
|
-
<div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:release_tag</span><span class="p">)</span> <span class="p">{</span> <span class="s2">"</span><span class="si">#{</span><span class="no">Time</span><span class="o">.</span><span class="n">now</span><span class="o">.</span><span class="n">utc</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">"%Y%m%d%H%M%S"</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">}</span></pre></div>
|
122
|
-
</td>
|
123
|
-
</tr>
|
124
|
-
<tr id='section-7'>
|
125
|
-
<td class=docs>
|
126
|
-
<div class="pilwrap">
|
127
|
-
<a class="pilcrow" href="#section-7">¶</a>
|
128
|
-
</div>
|
129
|
-
<p>On tagging a release, a message is also recorded alongside the tag. This message can contain
|
130
|
-
anything useful – its contents are not important for the recipe.</p>
|
131
|
-
</td>
|
132
|
-
<td class=code>
|
133
|
-
<div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:release_message</span><span class="p">,</span> <span class="s2">"Deployed at </span><span class="si">#{</span><span class="no">Time</span><span class="o">.</span><span class="n">now</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span></pre></div>
|
134
|
-
</td>
|
135
|
-
</tr>
|
136
|
-
<tr id='section-8'>
|
137
|
-
<td class=docs>
|
138
|
-
<div class="pilwrap">
|
139
|
-
<a class="pilcrow" href="#section-8">¶</a>
|
140
|
-
</div>
|
141
|
-
<p>Some tasks need to know the <code>latest_tag</code> – the most recent successful deployment. If no
|
142
|
-
deployments have been made, this will be <code>nil</code>.</p>
|
143
|
-
</td>
|
144
|
-
<td class=code>
|
145
|
-
<div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:latest_tag</span><span class="p">)</span> <span class="p">{</span> <span class="n">latest_tag_from_repository</span> <span class="p">}</span></pre></div>
|
146
|
-
</td>
|
147
|
-
</tr>
|
148
|
-
<tr id='section-9'>
|
149
|
-
<td class=docs>
|
150
|
-
<div class="pilwrap">
|
151
|
-
<a class="pilcrow" href="#section-9">¶</a>
|
152
|
-
</div>
|
153
|
-
<p>To authenticate with github or other git servers, it is easier (and cleaner) to forward the
|
154
|
-
deploying user’s ssh key than manage keys on deployment servers.</p>
|
155
|
-
</td>
|
156
|
-
<td class=code>
|
157
|
-
<div class='highlight'><pre> <span class="n">ssh_options</span><span class="o">[</span><span class="ss">:forward_agent</span><span class="o">]</span> <span class="o">=</span> <span class="kp">true</span></pre></div>
|
158
|
-
</td>
|
159
|
-
</tr>
|
160
|
-
<tr id='section-10'>
|
161
|
-
<td class=docs>
|
162
|
-
<div class="pilwrap">
|
163
|
-
<a class="pilcrow" href="#section-10">¶</a>
|
164
|
-
</div>
|
165
|
-
<p>If key forwarding isn’t possible, git may show a password prompt which stalls capistrano unless
|
166
|
-
<code>:pty</code> is set to <code>true</code>.</p>
|
167
|
-
</td>
|
168
|
-
<td class=code>
|
169
|
-
<div class='highlight'><pre> <span class="n">default_run_options</span><span class="o">[</span><span class="ss">:pty</span><span class="o">]</span> <span class="o">=</span> <span class="kp">true</span></pre></div>
|
170
|
-
</td>
|
171
|
-
</tr>
|
172
|
-
<tr id='section-11'>
|
173
|
-
<td class=docs>
|
174
|
-
<div class="pilwrap">
|
175
|
-
<a class="pilcrow" href="#section-11">¶</a>
|
176
|
-
</div>
|
177
|
-
<p>The <code>deploy:setup</code> task prepares all the servers for the deployment.</p>
|
178
|
-
</td>
|
179
|
-
<td class=code>
|
180
|
-
<div class='highlight'><pre> <span class="n">desc</span> <span class="s2">"Prepare servers for deployment"</span>
|
181
|
-
<span class="n">task</span> <span class="ss">:setup</span><span class="p">,</span> <span class="ss">:except</span> <span class="o">=></span> <span class="p">{</span><span class="ss">:no_release</span> <span class="o">=></span> <span class="kp">true</span><span class="p">}</span> <span class="k">do</span>
|
182
|
-
<span class="n">transaction</span> <span class="k">do</span>
|
183
|
-
<span class="n">clone_code</span>
|
184
|
-
<span class="k">end</span>
|
185
|
-
<span class="k">end</span></pre></div>
|
186
|
-
</td>
|
187
|
-
</tr>
|
188
|
-
<tr id='section-12'>
|
189
|
-
<td class=docs>
|
190
|
-
<div class="pilwrap">
|
191
|
-
<a class="pilcrow" href="#section-12">¶</a>
|
192
|
-
</div>
|
193
|
-
<p>Clone the repository into the deployment directory.</p>
|
194
|
-
</td>
|
195
|
-
<td class=code>
|
196
|
-
<div class='highlight'><pre> <span class="n">task</span> <span class="ss">:clone_code</span><span class="p">,</span> <span class="ss">:except</span> <span class="o">=></span> <span class="p">{</span><span class="ss">:no_release</span> <span class="o">=></span> <span class="kp">true</span><span class="p">}</span> <span class="k">do</span></pre></div>
|
197
|
-
</td>
|
198
|
-
</tr>
|
199
|
-
<tr id='section-13'>
|
200
|
-
<td class=docs>
|
201
|
-
<div class="pilwrap">
|
202
|
-
<a class="pilcrow" href="#section-13">¶</a>
|
203
|
-
</div>
|
204
|
-
<p>Before cloning, the directory needs to exist and be both readable and writable by the group</p>
|
205
|
-
</td>
|
206
|
-
<td class=code>
|
207
|
-
<div class='highlight'><pre> <span class="n">as_app</span> <span class="s2">"mkdir -p </span><span class="si">#{</span><span class="n">deploy_to</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"~"</span>
|
208
|
-
<span class="n">as_app</span> <span class="s2">"chmod g+rw </span><span class="si">#{</span><span class="n">deploy_to</span><span class="si">}</span><span class="s2">"</span></pre></div>
|
209
|
-
</td>
|
210
|
-
</tr>
|
211
|
-
<tr id='section-14'>
|
212
|
-
<td class=docs>
|
213
|
-
<div class="pilwrap">
|
214
|
-
<a class="pilcrow" href="#section-14">¶</a>
|
215
|
-
</div>
|
216
|
-
<p>Then clone the code</p>
|
217
|
-
</td>
|
218
|
-
<td class=code>
|
219
|
-
<div class='highlight'><pre> <span class="n">git</span> <span class="s2">"clone </span><span class="si">#{</span><span class="n">repository</span><span class="si">}</span><span class="s2"> ."</span>
|
220
|
-
<span class="k">end</span></pre></div>
|
221
|
-
</td>
|
222
|
-
</tr>
|
223
|
-
<tr id='section-15'>
|
224
|
-
<td class=docs>
|
225
|
-
<div class="pilwrap">
|
226
|
-
<a class="pilcrow" href="#section-15">¶</a>
|
227
|
-
</div>
|
228
|
-
<p>The main deployment task (called with <code>cap deploy</code>) deploys the latest application code to all
|
229
|
-
servers, tags the release and restarts the application.</p>
|
230
|
-
</td>
|
231
|
-
<td class=code>
|
232
|
-
<div class='highlight'><pre> <span class="n">desc</span> <span class="s2">"Deploy the latest application code"</span>
|
233
|
-
<span class="n">task</span> <span class="ss">:default</span> <span class="k">do</span>
|
234
|
-
<span class="n">transaction</span> <span class="k">do</span>
|
235
|
-
<span class="n">update_code</span>
|
236
|
-
<span class="n">tag</span>
|
237
|
-
<span class="k">end</span>
|
238
|
-
<span class="n">restart</span>
|
239
|
-
<span class="k">end</span></pre></div>
|
240
|
-
</td>
|
241
|
-
</tr>
|
242
|
-
<tr id='section-16'>
|
243
|
-
<td class=docs>
|
244
|
-
<div class="pilwrap">
|
245
|
-
<a class="pilcrow" href="#section-16">¶</a>
|
246
|
-
</div>
|
247
|
-
<p>Fetch the latest changes, then update <code>HEAD</code> to the deployment branch.</p>
|
248
|
-
</td>
|
249
|
-
<td class=code>
|
250
|
-
<div class='highlight'><pre> <span class="n">task</span> <span class="ss">:update_code</span><span class="p">,</span> <span class="ss">:except</span> <span class="o">=></span> <span class="p">{</span><span class="ss">:no_release</span> <span class="o">=></span> <span class="kp">true</span><span class="p">}</span> <span class="k">do</span>
|
251
|
-
<span class="n">on_rollback</span> <span class="p">{</span> <span class="n">git</span> <span class="s2">"reset --hard </span><span class="si">#{</span><span class="n">latest_tag</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">latest_tag</span> <span class="p">}</span>
|
252
|
-
<span class="n">git</span> <span class="s2">"fetch"</span>
|
253
|
-
<span class="n">git</span> <span class="s2">"reset --hard origin/</span><span class="si">#{</span><span class="n">branch</span><span class="si">}</span><span class="s2">"</span>
|
254
|
-
<span class="k">end</span></pre></div>
|
255
|
-
</td>
|
256
|
-
</tr>
|
257
|
-
<tr id='section-17'>
|
258
|
-
<td class=docs>
|
259
|
-
<div class="pilwrap">
|
260
|
-
<a class="pilcrow" href="#section-17">¶</a>
|
261
|
-
</div>
|
262
|
-
<p>Tag <code>HEAD</code> with the release tag and message</p>
|
263
|
-
</td>
|
264
|
-
<td class=code>
|
265
|
-
<div class='highlight'><pre> <span class="n">task</span> <span class="ss">:tag</span><span class="p">,</span> <span class="ss">:except</span> <span class="o">=></span> <span class="p">{</span><span class="ss">:no_release</span> <span class="o">=></span> <span class="kp">true</span><span class="p">}</span> <span class="k">do</span>
|
266
|
-
<span class="n">on_rollback</span> <span class="p">{</span> <span class="n">git</span> <span class="s2">"tag -d </span><span class="si">#{</span><span class="n">release_tag</span><span class="si">}</span><span class="s2">"</span> <span class="p">}</span>
|
267
|
-
<span class="n">git</span> <span class="s2">"tag </span><span class="si">#{</span><span class="n">release_tag</span><span class="si">}</span><span class="s2"> -m '</span><span class="si">#{</span><span class="n">release_message</span><span class="si">}</span><span class="s2">'"</span>
|
268
|
-
<span class="k">end</span></pre></div>
|
269
|
-
</td>
|
270
|
-
</tr>
|
271
|
-
<tr id='section-18'>
|
272
|
-
<td class=docs>
|
273
|
-
<div class="pilwrap">
|
274
|
-
<a class="pilcrow" href="#section-18">¶</a>
|
275
|
-
</div>
|
276
|
-
<p>After a successful deployment, the app is restarted. In the most basic deployments this does
|
277
|
-
nothing, but other recipes may override it, or attach tasks it’s before or after hooks.</p>
|
278
|
-
</td>
|
279
|
-
<td class=code>
|
280
|
-
<div class='highlight'><pre> <span class="n">desc</span> <span class="s2">"Restart the application following a deploy"</span>
|
281
|
-
<span class="n">task</span> <span class="ss">:restart</span> <span class="k">do</span>
|
282
|
-
<span class="k">end</span></pre></div>
|
283
|
-
</td>
|
284
|
-
</tr>
|
285
|
-
<tr id='section-19'>
|
286
|
-
<td class=docs>
|
287
|
-
<div class="pilwrap">
|
288
|
-
<a class="pilcrow" href="#section-19">¶</a>
|
289
|
-
</div>
|
290
|
-
<p>To rollback a release, the latest tag is deleted, and <code>HEAD</code> reset to the previous release
|
291
|
-
(if one exists). Finally the application is restarted again.</p>
|
292
|
-
</td>
|
293
|
-
<td class=code>
|
294
|
-
<div class='highlight'><pre> <span class="n">desc</span> <span class="s2">"Rollback to the previous release"</span>
|
295
|
-
<span class="n">namespace</span> <span class="ss">:rollback</span> <span class="k">do</span>
|
296
|
-
<span class="n">task</span> <span class="ss">:default</span> <span class="k">do</span>
|
297
|
-
<span class="k">if</span> <span class="n">latest_tag</span>
|
298
|
-
<span class="n">git</span> <span class="s2">"tag -d </span><span class="si">#{</span><span class="n">latest_tag</span><span class="si">}</span><span class="s2">"</span>
|
299
|
-
<span class="k">if</span> <span class="n">previous_tag</span> <span class="o">=</span> <span class="n">latest_tag_from_repository</span>
|
300
|
-
<span class="n">git</span> <span class="s2">"reset --hard </span><span class="si">#{</span><span class="n">previous_tag</span><span class="si">}</span><span class="s2">"</span>
|
301
|
-
<span class="k">end</span>
|
302
|
-
<span class="k">end</span>
|
303
|
-
<span class="n">restart</span>
|
304
|
-
<span class="k">end</span>
|
305
|
-
<span class="k">end</span></pre></div>
|
306
|
-
</td>
|
307
|
-
</tr>
|
308
|
-
<tr id='section-20'>
|
309
|
-
<td class=docs>
|
310
|
-
<div class="pilwrap">
|
311
|
-
<a class="pilcrow" href="#section-20">¶</a>
|
312
|
-
</div>
|
313
|
-
<p>In case of emergency or when manually testing deployment, it can be useful to remove all
|
314
|
-
previously deployed files before starting again.</p>
|
315
|
-
|
316
|
-
</td>
|
317
|
-
<td class=code>
|
318
|
-
<div class='highlight'><pre> <span class="n">desc</span> <span class="s2">"Remove all deployed files"</span>
|
319
|
-
<span class="n">task</span> <span class="ss">:destroy</span> <span class="k">do</span>
|
320
|
-
<span class="n">sudo</span> <span class="s2">"rm -rf </span><span class="si">#{</span><span class="n">deploy_to</span><span class="si">}</span><span class="s2">"</span>
|
321
|
-
<span class="k">end</span>
|
322
|
-
<span class="k">end</span>
|
323
|
-
<span class="k">end</span></pre></div>
|
324
|
-
</td>
|
325
|
-
</tr>
|
326
|
-
</table>
|
327
|
-
</div>
|
328
|
-
</body>
|
data/doc/lib/recap/env.html
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
-
<title>env.rb</title>
|
6
|
-
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<div id='container'>
|
10
|
-
<div id="background"></div>
|
11
|
-
<div id="jump_to">
|
12
|
-
Jump To …
|
13
|
-
<div id="jump_wrapper">
|
14
|
-
<div id="jump_page">
|
15
|
-
<a class="source" href="../../index.html">index.rb</a>
|
16
|
-
<a class="source" href="../recap.html">recap.rb</a>
|
17
|
-
<a class="source" href="bootstrap.html">bootstrap.rb</a>
|
18
|
-
<a class="source" href="bundler.html">bundler.rb</a>
|
19
|
-
<a class="source" href="capistrano_extensions.html">capistrano_extensions.rb</a>
|
20
|
-
<a class="source" href="cli.html">cli.rb</a>
|
21
|
-
<a class="source" href="compatibility.html">compatibility.rb</a>
|
22
|
-
<a class="source" href="deploy.html">deploy.rb</a>
|
23
|
-
<a class="source" href="env.html">env.rb</a>
|
24
|
-
<a class="source" href="foreman.html">foreman.rb</a>
|
25
|
-
<a class="source" href="namespace.html">namespace.rb</a>
|
26
|
-
<a class="source" href="preflight.html">preflight.rb</a>
|
27
|
-
<a class="source" href="rails.html">rails.rb</a>
|
28
|
-
<a class="source" href="version.html">version.rb</a>
|
29
|
-
</div>
|
30
|
-
</div>
|
31
|
-
</div>
|
32
|
-
<table cellspacing=0 cellpadding=0>
|
33
|
-
<thead>
|
34
|
-
<tr>
|
35
|
-
<th class=docs><h1>env.rb</h1></th>
|
36
|
-
<th class=code></th>
|
37
|
-
</tr>
|
38
|
-
</thead>
|
39
|
-
<tbody>
|
40
|
-
<tr id='section-1'>
|
41
|
-
<td class=docs>
|
42
|
-
<div class="pilwrap">
|
43
|
-
<a class="pilcrow" href="#section-1">¶</a>
|
44
|
-
</div>
|
45
|
-
<p>N.B. To get the environment loaded on every shell invocation add the following to .profile:</p>
|
46
|
-
|
47
|
-
<pre><code>if [ -s “$HOME/.env” ]; then export $(cat $HOME/.env); fi
|
48
|
-
</code></pre>
|
49
|
-
|
50
|
-
<p>This will eventually be done automatically</p>
|
51
|
-
|
52
|
-
</td>
|
53
|
-
<td class=code>
|
54
|
-
<div class='highlight'><pre><span class="k">module</span> <span class="nn">Recap::Env</span>
|
55
|
-
<span class="kp">extend</span> <span class="no">Recap</span><span class="o">::</span><span class="no">Namespace</span>
|
56
|
-
|
57
|
-
<span class="n">namespace</span> <span class="ss">:env</span> <span class="k">do</span>
|
58
|
-
<span class="n">set</span><span class="p">(</span><span class="ss">:environment_file</span><span class="p">)</span> <span class="p">{</span> <span class="s2">"/home/</span><span class="si">#{</span><span class="n">application_user</span><span class="si">}</span><span class="s2">/.env"</span> <span class="p">}</span>
|
59
|
-
|
60
|
-
<span class="k">def</span> <span class="nf">extract_environment</span><span class="p">(</span><span class="n">declarations</span><span class="p">)</span>
|
61
|
-
<span class="n">declarations</span><span class="o">.</span><span class="n">inject</span><span class="p">({})</span> <span class="k">do</span> <span class="o">|</span><span class="n">env</span><span class="p">,</span> <span class="n">line</span><span class="o">|</span>
|
62
|
-
<span class="k">if</span> <span class="n">line</span> <span class="o">=~</span> <span class="sr">/\A([A-Za-z_]+)=(.*)\z/</span>
|
63
|
-
<span class="n">env</span><span class="o">[</span><span class="vg">$1</span><span class="o">]</span> <span class="o">=</span> <span class="vg">$2</span><span class="o">.</span><span class="n">strip</span>
|
64
|
-
<span class="k">end</span>
|
65
|
-
<span class="n">env</span>
|
66
|
-
<span class="k">end</span>
|
67
|
-
<span class="k">end</span>
|
68
|
-
|
69
|
-
<span class="k">def</span> <span class="nf">current_environment</span>
|
70
|
-
<span class="vi">@current_environment</span> <span class="o">||=</span> <span class="k">begin</span>
|
71
|
-
<span class="k">if</span> <span class="n">deployed_file_exists?</span><span class="p">(</span><span class="n">environment_file</span><span class="p">)</span>
|
72
|
-
<span class="n">extract_environment</span><span class="p">(</span><span class="n">capture</span><span class="p">(</span><span class="s2">"cat </span><span class="si">#{</span><span class="n">environment_file</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">))</span>
|
73
|
-
<span class="k">else</span>
|
74
|
-
<span class="p">{}</span>
|
75
|
-
<span class="k">end</span>
|
76
|
-
<span class="k">end</span>
|
77
|
-
<span class="k">end</span>
|
78
|
-
|
79
|
-
<span class="k">def</span> <span class="nf">write_environment</span><span class="p">(</span><span class="n">env</span><span class="p">)</span>
|
80
|
-
<span class="n">env</span><span class="o">.</span><span class="n">keys</span><span class="o">.</span><span class="n">sort</span><span class="o">.</span><span class="n">collect</span> <span class="k">do</span> <span class="o">|</span><span class="n">v</span><span class="o">|</span>
|
81
|
-
<span class="s2">"</span><span class="si">#{</span><span class="n">v</span><span class="si">}</span><span class="s2">=</span><span class="si">#{</span><span class="n">env</span><span class="o">[</span><span class="n">v</span><span class="o">]</span><span class="si">}</span><span class="s2">"</span> <span class="k">unless</span> <span class="n">env</span><span class="o">[</span><span class="n">v</span><span class="o">].</span><span class="n">nil?</span> <span class="o">||</span> <span class="n">env</span><span class="o">[</span><span class="n">v</span><span class="o">].</span><span class="n">empty?</span>
|
82
|
-
<span class="k">end</span><span class="o">.</span><span class="n">compact</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span>
|
83
|
-
<span class="k">end</span>
|
84
|
-
|
85
|
-
<span class="n">task</span> <span class="ss">:default</span> <span class="k">do</span>
|
86
|
-
<span class="nb">puts</span> <span class="n">write_environment</span><span class="p">(</span><span class="n">current_environment</span><span class="p">)</span>
|
87
|
-
<span class="k">end</span>
|
88
|
-
|
89
|
-
<span class="n">task</span> <span class="ss">:set</span> <span class="k">do</span>
|
90
|
-
<span class="n">additions</span> <span class="o">=</span> <span class="n">extract_environment</span><span class="p">(</span><span class="no">ARGV</span><span class="o">[</span><span class="mi">1</span><span class="o">.</span><span class="n">.</span><span class="o">-</span><span class="mi">1</span><span class="o">]</span><span class="p">)</span>
|
91
|
-
<span class="n">env</span> <span class="o">=</span> <span class="n">write_environment</span><span class="p">(</span><span class="n">current_environment</span><span class="o">.</span><span class="n">merge</span><span class="p">(</span><span class="n">additions</span><span class="p">))</span>
|
92
|
-
<span class="k">if</span> <span class="n">env</span><span class="o">.</span><span class="n">empty?</span>
|
93
|
-
<span class="n">as_app</span> <span class="s2">"rm -f </span><span class="si">#{</span><span class="n">environment_file</span><span class="si">}</span><span class="s2">"</span>
|
94
|
-
<span class="k">else</span>
|
95
|
-
<span class="n">put_as_app</span> <span class="n">env</span><span class="p">,</span> <span class="n">environment_file</span>
|
96
|
-
<span class="k">end</span>
|
97
|
-
<span class="k">end</span>
|
98
|
-
|
99
|
-
<span class="n">task</span> <span class="ss">:edit</span> <span class="k">do</span>
|
100
|
-
<span class="n">edit_file</span> <span class="n">environment_file</span>
|
101
|
-
<span class="k">end</span>
|
102
|
-
<span class="k">end</span>
|
103
|
-
<span class="k">end</span></pre></div>
|
104
|
-
</td>
|
105
|
-
</tr>
|
106
|
-
</table>
|
107
|
-
</div>
|
108
|
-
</body>
|
data/doc/lib/recap/foreman.html
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
-
<title>foreman.rb</title>
|
6
|
-
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<div id='container'>
|
10
|
-
<div id="background"></div>
|
11
|
-
<div id="jump_to">
|
12
|
-
Jump To …
|
13
|
-
<div id="jump_wrapper">
|
14
|
-
<div id="jump_page">
|
15
|
-
<a class="source" href="../../index.html">index.rb</a>
|
16
|
-
<a class="source" href="../recap.html">recap.rb</a>
|
17
|
-
<a class="source" href="bootstrap.html">bootstrap.rb</a>
|
18
|
-
<a class="source" href="bundler.html">bundler.rb</a>
|
19
|
-
<a class="source" href="capistrano_extensions.html">capistrano_extensions.rb</a>
|
20
|
-
<a class="source" href="cli.html">cli.rb</a>
|
21
|
-
<a class="source" href="compatibility.html">compatibility.rb</a>
|
22
|
-
<a class="source" href="deploy.html">deploy.rb</a>
|
23
|
-
<a class="source" href="env.html">env.rb</a>
|
24
|
-
<a class="source" href="foreman.html">foreman.rb</a>
|
25
|
-
<a class="source" href="namespace.html">namespace.rb</a>
|
26
|
-
<a class="source" href="preflight.html">preflight.rb</a>
|
27
|
-
<a class="source" href="rails.html">rails.rb</a>
|
28
|
-
<a class="source" href="version.html">version.rb</a>
|
29
|
-
</div>
|
30
|
-
</div>
|
31
|
-
</div>
|
32
|
-
<table cellspacing=0 cellpadding=0>
|
33
|
-
<thead>
|
34
|
-
<tr>
|
35
|
-
<th class=docs><h1>foreman.rb</h1></th>
|
36
|
-
<th class=code></th>
|
37
|
-
</tr>
|
38
|
-
</thead>
|
39
|
-
<tbody>
|
40
|
-
</table>
|
41
|
-
</div>
|
42
|
-
</body>
|
@@ -1,42 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
-
<title>namespace.rb</title>
|
6
|
-
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<div id='container'>
|
10
|
-
<div id="background"></div>
|
11
|
-
<div id="jump_to">
|
12
|
-
Jump To …
|
13
|
-
<div id="jump_wrapper">
|
14
|
-
<div id="jump_page">
|
15
|
-
<a class="source" href="../../index.html">index.rb</a>
|
16
|
-
<a class="source" href="../recap.html">recap.rb</a>
|
17
|
-
<a class="source" href="bootstrap.html">bootstrap.rb</a>
|
18
|
-
<a class="source" href="bundler.html">bundler.rb</a>
|
19
|
-
<a class="source" href="capistrano_extensions.html">capistrano_extensions.rb</a>
|
20
|
-
<a class="source" href="cli.html">cli.rb</a>
|
21
|
-
<a class="source" href="compatibility.html">compatibility.rb</a>
|
22
|
-
<a class="source" href="deploy.html">deploy.rb</a>
|
23
|
-
<a class="source" href="env.html">env.rb</a>
|
24
|
-
<a class="source" href="foreman.html">foreman.rb</a>
|
25
|
-
<a class="source" href="namespace.html">namespace.rb</a>
|
26
|
-
<a class="source" href="preflight.html">preflight.rb</a>
|
27
|
-
<a class="source" href="rails.html">rails.rb</a>
|
28
|
-
<a class="source" href="version.html">version.rb</a>
|
29
|
-
</div>
|
30
|
-
</div>
|
31
|
-
</div>
|
32
|
-
<table cellspacing=0 cellpadding=0>
|
33
|
-
<thead>
|
34
|
-
<tr>
|
35
|
-
<th class=docs><h1>namespace.rb</h1></th>
|
36
|
-
<th class=code></th>
|
37
|
-
</tr>
|
38
|
-
</thead>
|
39
|
-
<tbody>
|
40
|
-
</table>
|
41
|
-
</div>
|
42
|
-
</body>
|