recap 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.travis.yml +4 -0
- data/README.md +12 -3
- data/Rakefile +8 -0
- data/Vagrantfile +61 -0
- data/doc/index.html +45 -26
- data/doc/lib/recap/bootstrap.html +42 -0
- data/doc/lib/recap/bundler.html +36 -19
- data/doc/lib/recap/capistrano_extensions.html +28 -23
- data/doc/lib/recap/cli.html +3 -0
- data/doc/lib/recap/compatibility.html +6 -3
- data/doc/lib/recap/deploy.html +41 -86
- data/doc/lib/recap/env.html +6 -1
- data/doc/lib/recap/foreman.html +3 -0
- data/doc/lib/recap/namespace.html +42 -0
- data/doc/lib/recap/preflight.html +12 -7
- data/doc/lib/recap/rails.html +3 -0
- data/doc/lib/recap/version.html +3 -0
- data/doc/lib/recap.html +42 -0
- data/features/bundling-gems.feature +18 -0
- data/features/deploying-projects.feature +21 -0
- data/features/managing-processes.feature +17 -0
- data/features/setting-environment-variables.feature +21 -0
- data/features/steps/capistrano_steps.rb +98 -0
- data/features/support/project.rb +211 -0
- data/features/support/server.rb +53 -0
- data/features/templates/gem/binary.erb +43 -0
- data/features/templates/gem/gemspec.erb +11 -0
- data/features/templates/project/Capfile +21 -0
- data/features/templates/project/Capfile.erb +21 -0
- data/features/templates/project/Gemfile.erb +7 -0
- data/features/templates/project/Procfile.erb +1 -0
- data/index.rb +26 -17
- data/lib/recap/bootstrap.rb +47 -0
- data/lib/recap/bundler.rb +31 -21
- data/lib/recap/capistrano_extensions.rb +11 -9
- data/lib/recap/cli.rb +1 -1
- data/lib/recap/compatibility.rb +3 -3
- data/lib/recap/deploy.rb +45 -57
- data/lib/recap/env.rb +30 -26
- data/lib/recap/environment.rb +54 -0
- data/lib/recap/foreman.rb +28 -9
- data/lib/recap/namespace.rb +37 -0
- data/lib/recap/preflight.rb +10 -8
- data/lib/recap/rails.rb +6 -4
- data/lib/recap/ruby.rb +3 -0
- data/lib/recap/static.rb +1 -0
- data/lib/recap/version.rb +1 -1
- data/lib/recap.rb +12 -0
- data/recap.gemspec +8 -4
- data/spec/models/environment_spec.rb +143 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/tasks/bootstrap_spec.rb +34 -0
- data/spec/tasks/bundler_spec.rb +126 -0
- data/spec/tasks/deploy_spec.rb +209 -0
- data/spec/tasks/env_spec.rb +38 -0
- data/spec/tasks/foreman_spec.rb +154 -0
- data/test-vm/manifests/base.pp +17 -0
- data/test-vm/share/.gitkeep +0 -0
- metadata +138 -19
- /data/bin/{tomafro-deploy → recap} +0 -0
@@ -13,6 +13,8 @@
|
|
13
13
|
<div id="jump_wrapper">
|
14
14
|
<div id="jump_page">
|
15
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>
|
16
18
|
<a class="source" href="bundler.html">bundler.rb</a>
|
17
19
|
<a class="source" href="capistrano_extensions.html">capistrano_extensions.rb</a>
|
18
20
|
<a class="source" href="cli.html">cli.rb</a>
|
@@ -20,6 +22,7 @@
|
|
20
22
|
<a class="source" href="deploy.html">deploy.rb</a>
|
21
23
|
<a class="source" href="env.html">env.rb</a>
|
22
24
|
<a class="source" href="foreman.html">foreman.rb</a>
|
25
|
+
<a class="source" href="namespace.html">namespace.rb</a>
|
23
26
|
<a class="source" href="preflight.html">preflight.rb</a>
|
24
27
|
<a class="source" href="rails.html">rails.rb</a>
|
25
28
|
<a class="source" href="version.html">version.rb</a>
|
@@ -98,18 +101,6 @@
|
|
98
101
|
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">put_as_app</span><span class="p">(</span><span class="n">string</span><span class="p">,</span> <span class="n">path</span><span class="p">)</span>
|
99
102
|
<span class="n">as_app</span> <span class="s2">"touch </span><span class="si">#{</span><span class="n">path</span><span class="si">}</span><span class="s2"> && chmod g+rw </span><span class="si">#{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span>
|
100
103
|
<span class="n">put</span> <span class="n">string</span><span class="p">,</span> <span class="n">path</span>
|
101
|
-
<span class="k">end</span>
|
102
|
-
|
103
|
-
<span class="k">def</span> <span class="nf">edit_file</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
104
|
-
<span class="k">if</span> <span class="n">editor</span> <span class="o">=</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">'DEPLOY_EDITOR'</span><span class="o">]</span> <span class="o">||</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">'EDITOR'</span><span class="o">]</span>
|
105
|
-
<span class="n">as_app</span> <span class="s2">"touch </span><span class="si">#{</span><span class="n">path</span><span class="si">}</span><span class="s2"> && chmod g+rw </span><span class="si">#{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span>
|
106
|
-
<span class="n">local_path</span> <span class="o">=</span> <span class="no">Tempfile</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="s1">'deploy-edit'</span><span class="p">)</span><span class="o">.</span><span class="n">path</span>
|
107
|
-
<span class="n">get</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">local_path</span><span class="p">)</span>
|
108
|
-
<span class="sb">`</span><span class="si">#{</span><span class="n">editor</span><span class="si">}</span><span class="sb"> </span><span class="si">#{</span><span class="n">local_path</span><span class="si">}</span><span class="sb">`</span>
|
109
|
-
<span class="n">upload</span><span class="p">(</span><span class="n">local_path</span><span class="p">,</span> <span class="n">path</span><span class="p">)</span>
|
110
|
-
<span class="k">else</span>
|
111
|
-
<span class="nb">abort</span> <span class="s2">"To edit a remote file, either the EDITOR or DEPLOY_EDITOR environment variables must be set"</span>
|
112
|
-
<span class="k">end</span>
|
113
104
|
<span class="k">end</span></pre></div>
|
114
105
|
</td>
|
115
106
|
</tr>
|
@@ -118,11 +109,19 @@
|
|
118
109
|
<div class="pilwrap">
|
119
110
|
<a class="pilcrow" href="#section-6">¶</a>
|
120
111
|
</div>
|
121
|
-
<p>
|
112
|
+
<p>Edit a file on the remote server, using a local editor</p>
|
122
113
|
</td>
|
123
114
|
<td class=code>
|
124
|
-
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">
|
125
|
-
<span class="
|
115
|
+
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">edit_file</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
116
|
+
<span class="k">if</span> <span class="n">editor</span> <span class="o">=</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">'DEPLOY_EDITOR'</span><span class="o">]</span> <span class="o">||</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">'EDITOR'</span><span class="o">]</span>
|
117
|
+
<span class="n">as_app</span> <span class="s2">"touch </span><span class="si">#{</span><span class="n">path</span><span class="si">}</span><span class="s2"> && chmod g+rw </span><span class="si">#{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span>
|
118
|
+
<span class="n">local_path</span> <span class="o">=</span> <span class="no">Tempfile</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="s1">'deploy-edit'</span><span class="p">)</span><span class="o">.</span><span class="n">path</span>
|
119
|
+
<span class="n">get</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">local_path</span><span class="p">)</span>
|
120
|
+
<span class="sb">`</span><span class="si">#{</span><span class="n">editor</span><span class="si">}</span><span class="sb"> </span><span class="si">#{</span><span class="n">local_path</span><span class="si">}</span><span class="sb">`</span>
|
121
|
+
<span class="n">upload</span><span class="p">(</span><span class="n">local_path</span><span class="p">,</span> <span class="n">path</span><span class="p">)</span>
|
122
|
+
<span class="k">else</span>
|
123
|
+
<span class="nb">abort</span> <span class="s2">"To edit a remote file, either the EDITOR or DEPLOY_EDITOR environment variables must be set"</span>
|
124
|
+
<span class="k">end</span>
|
126
125
|
<span class="k">end</span></pre></div>
|
127
126
|
</td>
|
128
127
|
</tr>
|
@@ -131,11 +130,11 @@
|
|
131
130
|
<div class="pilwrap">
|
132
131
|
<a class="pilcrow" href="#section-7">¶</a>
|
133
132
|
</div>
|
134
|
-
<p>
|
133
|
+
<p>Run a git command in the <code>deploy_to</code> directory</p>
|
135
134
|
</td>
|
136
135
|
<td class=code>
|
137
|
-
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">
|
138
|
-
<span class="n">
|
136
|
+
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">git</span><span class="p">(</span><span class="n">command</span><span class="p">)</span>
|
137
|
+
<span class="n">run</span> <span class="s2">"cd </span><span class="si">#{</span><span class="n">deploy_to</span><span class="si">}</span><span class="s2"> && umask 002 && sg </span><span class="si">#{</span><span class="n">application_group</span><span class="si">}</span><span class="s2"> -c </span><span class="se">\"</span><span class="s2">git </span><span class="si">#{</span><span class="n">command</span><span class="si">}</span><span class="se">\"</span><span class="s2">"</span>
|
139
138
|
<span class="k">end</span></pre></div>
|
140
139
|
</td>
|
141
140
|
</tr>
|
@@ -144,11 +143,15 @@
|
|
144
143
|
<div class="pilwrap">
|
145
144
|
<a class="pilcrow" href="#section-8">¶</a>
|
146
145
|
</div>
|
147
|
-
<p>
|
146
|
+
<p>Capture the result of a git command run within the <code>deploy_to</code> directory</p>
|
148
147
|
</td>
|
149
148
|
<td class=code>
|
150
|
-
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">
|
151
|
-
<span class="n">
|
149
|
+
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">capture_git</span><span class="p">(</span><span class="n">command</span><span class="p">)</span>
|
150
|
+
<span class="n">capture</span> <span class="s2">"cd </span><span class="si">#{</span><span class="n">deploy_to</span><span class="si">}</span><span class="s2"> && umask 002 && sg </span><span class="si">#{</span><span class="n">application_group</span><span class="si">}</span><span class="s2"> -c 'git </span><span class="si">#{</span><span class="n">command</span><span class="si">}</span><span class="s2">'"</span>
|
151
|
+
<span class="k">end</span>
|
152
|
+
|
153
|
+
<span class="k">def</span> <span class="nf">exit_code</span><span class="p">(</span><span class="n">command</span><span class="p">)</span>
|
154
|
+
<span class="n">capture</span><span class="p">(</span><span class="s2">"</span><span class="si">#{</span><span class="n">command</span><span class="si">}</span><span class="s2"> > /dev/null 2>&1; echo $?"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span>
|
152
155
|
<span class="k">end</span></pre></div>
|
153
156
|
</td>
|
154
157
|
</tr>
|
@@ -176,7 +179,7 @@ tags are timestamps, the latest tag will always be the last in the list.</p>
|
|
176
179
|
</td>
|
177
180
|
<td class=code>
|
178
181
|
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">deployed_file_exists?</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
179
|
-
<span class="n">
|
182
|
+
<span class="n">exit_code</span><span class="p">(</span><span class="s2">"cd </span><span class="si">#{</span><span class="n">deploy_to</span><span class="si">}</span><span class="s2"> && [ -f </span><span class="si">#{</span><span class="n">path</span><span class="si">}</span><span class="s2"> ]"</span><span class="p">)</span> <span class="o">==</span> <span class="s2">"0"</span>
|
180
183
|
<span class="k">end</span></pre></div>
|
181
184
|
</td>
|
182
185
|
</tr>
|
@@ -192,8 +195,10 @@ successful deployment this will always return true.</p>
|
|
192
195
|
<td class=code>
|
193
196
|
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">deployed_file_changed?</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
194
197
|
<span class="k">return</span> <span class="kp">true</span> <span class="k">unless</span> <span class="n">latest_tag</span>
|
195
|
-
<span class="n">
|
198
|
+
<span class="n">exit_code</span><span class="p">(</span><span class="s2">"cd </span><span class="si">#{</span><span class="n">deploy_to</span><span class="si">}</span><span class="s2"> && git diff --exit-code </span><span class="si">#{</span><span class="n">latest_tag</span><span class="si">}</span><span class="s2"> origin/</span><span class="si">#{</span><span class="n">branch</span><span class="si">}</span><span class="s2"> </span><span class="si">#{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="o">==</span> <span class="s2">"1"</span>
|
196
199
|
<span class="k">end</span>
|
200
|
+
|
201
|
+
<span class="no">Capistrano</span><span class="o">::</span><span class="no">Configuration</span><span class="o">.</span><span class="n">send</span> <span class="ss">:include</span><span class="p">,</span> <span class="nb">self</span>
|
197
202
|
<span class="k">end</span>
|
198
203
|
<span class="k">end</span></pre></div>
|
199
204
|
</td>
|
data/doc/lib/recap/cli.html
CHANGED
@@ -13,6 +13,8 @@
|
|
13
13
|
<div id="jump_wrapper">
|
14
14
|
<div id="jump_page">
|
15
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>
|
16
18
|
<a class="source" href="bundler.html">bundler.rb</a>
|
17
19
|
<a class="source" href="capistrano_extensions.html">capistrano_extensions.rb</a>
|
18
20
|
<a class="source" href="cli.html">cli.rb</a>
|
@@ -20,6 +22,7 @@
|
|
20
22
|
<a class="source" href="deploy.html">deploy.rb</a>
|
21
23
|
<a class="source" href="env.html">env.rb</a>
|
22
24
|
<a class="source" href="foreman.html">foreman.rb</a>
|
25
|
+
<a class="source" href="namespace.html">namespace.rb</a>
|
23
26
|
<a class="source" href="preflight.html">preflight.rb</a>
|
24
27
|
<a class="source" href="rails.html">rails.rb</a>
|
25
28
|
<a class="source" href="version.html">version.rb</a>
|
@@ -13,6 +13,8 @@
|
|
13
13
|
<div id="jump_wrapper">
|
14
14
|
<div id="jump_page">
|
15
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>
|
16
18
|
<a class="source" href="bundler.html">bundler.rb</a>
|
17
19
|
<a class="source" href="capistrano_extensions.html">capistrano_extensions.rb</a>
|
18
20
|
<a class="source" href="cli.html">cli.rb</a>
|
@@ -20,6 +22,7 @@
|
|
20
22
|
<a class="source" href="deploy.html">deploy.rb</a>
|
21
23
|
<a class="source" href="env.html">env.rb</a>
|
22
24
|
<a class="source" href="foreman.html">foreman.rb</a>
|
25
|
+
<a class="source" href="namespace.html">namespace.rb</a>
|
23
26
|
<a class="source" href="preflight.html">preflight.rb</a>
|
24
27
|
<a class="source" href="rails.html">rails.rb</a>
|
25
28
|
<a class="source" href="version.html">version.rb</a>
|
@@ -41,14 +44,14 @@
|
|
41
44
|
</div>
|
42
45
|
<p><code>recap</code> isn’t intended to be compatible with tasks (such as those within the <code>bundler</code>
|
43
46
|
or <code>whenever</code> projects) that are built on the original capistrano deployment recipes. At times
|
44
|
-
though there are tasks that would work, but for some missing (and redundant) settings
|
47
|
+
though there are tasks that would work, but for some missing (and redundant) settings.</p>
|
45
48
|
|
46
49
|
<p>Including this recipe adds these legacy settings, but provides no guarantee that original tasks
|
47
50
|
will work. Many are based on assumptions about the deployment layout that no longer hold true.</p>
|
48
51
|
</td>
|
49
52
|
<td class=code>
|
50
|
-
<div class='highlight'><pre><span class="
|
51
|
-
<span class="kp">extend</span> <span class="no">Recap</span><span class="o">::</span><span class="no">
|
53
|
+
<div class='highlight'><pre><span class="k">module</span> <span class="nn">Recap::Compatibility</span>
|
54
|
+
<span class="kp">extend</span> <span class="no">Recap</span><span class="o">::</span><span class="no">Namespace</span></pre></div>
|
52
55
|
</td>
|
53
56
|
</tr>
|
54
57
|
<tr id='section-2'>
|
data/doc/lib/recap/deploy.html
CHANGED
@@ -13,6 +13,8 @@
|
|
13
13
|
<div id="jump_wrapper">
|
14
14
|
<div id="jump_page">
|
15
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>
|
16
18
|
<a class="source" href="bundler.html">bundler.rb</a>
|
17
19
|
<a class="source" href="capistrano_extensions.html">capistrano_extensions.rb</a>
|
18
20
|
<a class="source" href="cli.html">cli.rb</a>
|
@@ -20,6 +22,7 @@
|
|
20
22
|
<a class="source" href="deploy.html">deploy.rb</a>
|
21
23
|
<a class="source" href="env.html">env.rb</a>
|
22
24
|
<a class="source" href="foreman.html">foreman.rb</a>
|
25
|
+
<a class="source" href="namespace.html">namespace.rb</a>
|
23
26
|
<a class="source" href="preflight.html">preflight.rb</a>
|
24
27
|
<a class="source" href="rails.html">rails.rb</a>
|
25
28
|
<a class="source" href="version.html">version.rb</a>
|
@@ -42,12 +45,18 @@
|
|
42
45
|
|
43
46
|
</td>
|
44
47
|
<td class=code>
|
45
|
-
<div class='highlight'><pre><span class="nb">require</span> <span class="s1">'recap
|
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>
|
46
52
|
<span class="nb">require</span> <span class="s1">'recap/bundler'</span>
|
53
|
+
<span class="nb">require</span> <span class="s1">'recap/env'</span>
|
47
54
|
<span class="nb">require</span> <span class="s1">'recap/preflight'</span>
|
48
55
|
|
49
|
-
<span class="
|
50
|
-
<span class="kp">extend</span> <span class="no">Recap</span><span class="o">::</span><span class="no">
|
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>
|
51
60
|
</td>
|
52
61
|
</tr>
|
53
62
|
<tr id='section-2'>
|
@@ -58,8 +67,8 @@
|
|
58
67
|
<p>To use this recipe, both the application’s name and its git repository are required.</p>
|
59
68
|
</td>
|
60
69
|
<td class=code>
|
61
|
-
<div class='highlight'><pre>
|
62
|
-
|
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>
|
63
72
|
</td>
|
64
73
|
</tr>
|
65
74
|
<tr id='section-3'>
|
@@ -72,8 +81,8 @@ can deploy the application should be added as a member of the application’
|
|
72
81
|
both the application user and group take the same name as the application.</p>
|
73
82
|
</td>
|
74
83
|
<td class=code>
|
75
|
-
<div class='highlight'><pre>
|
76
|
-
|
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>
|
77
86
|
</td>
|
78
87
|
</tr>
|
79
88
|
<tr id='section-4'>
|
@@ -84,7 +93,7 @@ both the application user and group take the same name as the application.</p>
|
|
84
93
|
<p>Deployments can be made from any branch. <code>master</code> is used by default.</p>
|
85
94
|
</td>
|
86
95
|
<td class=code>
|
87
|
-
<div class='highlight'><pre>
|
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>
|
88
97
|
</td>
|
89
98
|
</tr>
|
90
99
|
<tr id='section-5'>
|
@@ -93,10 +102,10 @@ both the application user and group take the same name as the application.</p>
|
|
93
102
|
<a class="pilcrow" href="#section-5">¶</a>
|
94
103
|
</div>
|
95
104
|
<p>Unlike a standard capistrano deployment, all releases are stored directly in the <code>deploy_to</code>
|
96
|
-
directory. The default is <code>/
|
105
|
+
directory. The default is <code>/home/#{application_user}/apps/#{application}</code>.</p>
|
97
106
|
</td>
|
98
107
|
<td class=code>
|
99
|
-
<div class='highlight'><pre>
|
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>
|
100
109
|
</td>
|
101
110
|
</tr>
|
102
111
|
<tr id='section-6'>
|
@@ -109,7 +118,7 @@ changed, it’s not recommended, as the sort order of the tag names is impor
|
|
109
118
|
be listed after earlier tags.</p>
|
110
119
|
</td>
|
111
120
|
<td class=code>
|
112
|
-
<div class='highlight'><pre>
|
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>
|
113
122
|
</td>
|
114
123
|
</tr>
|
115
124
|
<tr id='section-7'>
|
@@ -121,7 +130,7 @@ be listed after earlier tags.</p>
|
|
121
130
|
anything useful – its contents are not important for the recipe.</p>
|
122
131
|
</td>
|
123
132
|
<td class=code>
|
124
|
-
<div class='highlight'><pre>
|
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>
|
125
134
|
</td>
|
126
135
|
</tr>
|
127
136
|
<tr id='section-8'>
|
@@ -133,7 +142,7 @@ anything useful – its contents are not important for the recipe.</p>
|
|
133
142
|
deployments have been made, this will be <code>nil</code>.</p>
|
134
143
|
</td>
|
135
144
|
<td class=code>
|
136
|
-
<div class='highlight'><pre>
|
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>
|
137
146
|
</td>
|
138
147
|
</tr>
|
139
148
|
<tr id='section-9'>
|
@@ -145,7 +154,7 @@ deployments have been made, this will be <code>nil</code>.</p>
|
|
145
154
|
deploying user’s ssh key than manage keys on deployment servers.</p>
|
146
155
|
</td>
|
147
156
|
<td class=code>
|
148
|
-
<div class='highlight'><pre>
|
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>
|
149
158
|
</td>
|
150
159
|
</tr>
|
151
160
|
<tr id='section-10'>
|
@@ -157,9 +166,7 @@ deploying user’s ssh key than manage keys on deployment servers.</p>
|
|
157
166
|
<code>:pty</code> is set to <code>true</code>.</p>
|
158
167
|
</td>
|
159
168
|
<td class=code>
|
160
|
-
<div class='highlight'><pre>
|
161
|
-
|
162
|
-
<span class="n">namespace</span> <span class="ss">:deploy</span> <span class="k">do</span></pre></div>
|
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>
|
163
170
|
</td>
|
164
171
|
</tr>
|
165
172
|
<tr id='section-11'>
|
@@ -194,12 +201,11 @@ deploying user’s ssh key than manage keys on deployment servers.</p>
|
|
194
201
|
<div class="pilwrap">
|
195
202
|
<a class="pilcrow" href="#section-13">¶</a>
|
196
203
|
</div>
|
197
|
-
<p>
|
198
|
-
directory. To get around this, using <code>sudo</code> we create the base deployment folder (if it
|
199
|
-
doesn’t already exist).</p>
|
204
|
+
<p>Before cloning, the directory needs to exist and be both readable and writable by the group</p>
|
200
205
|
</td>
|
201
206
|
<td class=code>
|
202
|
-
<div class='highlight'><pre> <span class="n">
|
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>
|
203
209
|
</td>
|
204
210
|
</tr>
|
205
211
|
<tr id='section-14'>
|
@@ -207,11 +213,11 @@ doesn’t already exist).</p>
|
|
207
213
|
<div class="pilwrap">
|
208
214
|
<a class="pilcrow" href="#section-14">¶</a>
|
209
215
|
</div>
|
210
|
-
<p>
|
211
|
-
permission to write in the base deployment folder.</p>
|
216
|
+
<p>Then clone the code</p>
|
212
217
|
</td>
|
213
218
|
<td class=code>
|
214
|
-
<div class='highlight'><pre> <span class="n">
|
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>
|
215
221
|
</td>
|
216
222
|
</tr>
|
217
223
|
<tr id='section-15'>
|
@@ -219,45 +225,6 @@ permission to write in the base deployment folder.</p>
|
|
219
225
|
<div class="pilwrap">
|
220
226
|
<a class="pilcrow" href="#section-15">¶</a>
|
221
227
|
</div>
|
222
|
-
<p>Again using <code>sudo</code>, move the temporary clone to its final destination.</p>
|
223
|
-
</td>
|
224
|
-
<td class=code>
|
225
|
-
<div class='highlight'><pre> <span class="n">sudo</span> <span class="s2">"mv $HOME/</span><span class="si">#{</span><span class="n">application</span><span class="si">}</span><span class="s2">.tmp </span><span class="si">#{</span><span class="n">deploy_to</span><span class="si">}</span><span class="s2">"</span></pre></div>
|
226
|
-
</td>
|
227
|
-
</tr>
|
228
|
-
<tr id='section-16'>
|
229
|
-
<td class=docs>
|
230
|
-
<div class="pilwrap">
|
231
|
-
<a class="pilcrow" href="#section-16">¶</a>
|
232
|
-
</div>
|
233
|
-
<p>Finally ensure that members of the <code>application_group</code> can read and write all files.</p>
|
234
|
-
</td>
|
235
|
-
<td class=code>
|
236
|
-
<div class='highlight'><pre> <span class="n">top</span><span class="o">.</span><span class="n">deploy</span><span class="o">.</span><span class="n">change_ownership</span>
|
237
|
-
<span class="k">end</span></pre></div>
|
238
|
-
</td>
|
239
|
-
</tr>
|
240
|
-
<tr id='section-17'>
|
241
|
-
<td class=docs>
|
242
|
-
<div class="pilwrap">
|
243
|
-
<a class="pilcrow" href="#section-17">¶</a>
|
244
|
-
</div>
|
245
|
-
<p>Any files that have been created or updated by our user need to have thier permissions changed to
|
246
|
-
ensure they can be read and written by and member of the <code>application_group</code> (deploying users and
|
247
|
-
the application itself).</p>
|
248
|
-
</td>
|
249
|
-
<td class=code>
|
250
|
-
<div class='highlight'><pre> <span class="n">task</span> <span class="ss">:change_ownership</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">run</span> <span class="s2">"find </span><span class="si">#{</span><span class="n">deploy_to</span><span class="si">}</span><span class="s2"> -user `whoami` ! -group </span><span class="si">#{</span><span class="n">application_group</span><span class="si">}</span><span class="s2"> -exec chown :</span><span class="si">#{</span><span class="n">application_group</span><span class="si">}</span><span class="s2"> {} </span><span class="se">\\</span><span class="s2">;"</span>
|
252
|
-
<span class="n">run</span> <span class="s2">"find </span><span class="si">#{</span><span class="n">deploy_to</span><span class="si">}</span><span class="s2"> -user `whoami` -exec chmod g+rw {} </span><span class="se">\\</span><span class="s2">;"</span>
|
253
|
-
<span class="k">end</span></pre></div>
|
254
|
-
</td>
|
255
|
-
</tr>
|
256
|
-
<tr id='section-18'>
|
257
|
-
<td class=docs>
|
258
|
-
<div class="pilwrap">
|
259
|
-
<a class="pilcrow" href="#section-18">¶</a>
|
260
|
-
</div>
|
261
228
|
<p>The main deployment task (called with <code>cap deploy</code>) deploys the latest application code to all
|
262
229
|
servers, tags the release and restarts the application.</p>
|
263
230
|
</td>
|
@@ -272,10 +239,10 @@ servers, tags the release and restarts the application.</p>
|
|
272
239
|
<span class="k">end</span></pre></div>
|
273
240
|
</td>
|
274
241
|
</tr>
|
275
|
-
<tr id='section-
|
242
|
+
<tr id='section-16'>
|
276
243
|
<td class=docs>
|
277
244
|
<div class="pilwrap">
|
278
|
-
<a class="pilcrow" href="#section-
|
245
|
+
<a class="pilcrow" href="#section-16">¶</a>
|
279
246
|
</div>
|
280
247
|
<p>Fetch the latest changes, then update <code>HEAD</code> to the deployment branch.</p>
|
281
248
|
</td>
|
@@ -283,25 +250,14 @@ servers, tags the release and restarts the application.</p>
|
|
283
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>
|
284
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>
|
285
252
|
<span class="n">git</span> <span class="s2">"fetch"</span>
|
286
|
-
<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
|
287
|
-
</td>
|
288
|
-
</tr>
|
289
|
-
<tr id='section-20'>
|
290
|
-
<td class=docs>
|
291
|
-
<div class="pilwrap">
|
292
|
-
<a class="pilcrow" href="#section-20">¶</a>
|
293
|
-
</div>
|
294
|
-
<p>Finally ensure that the members of the <code>application_group</code> can read and write all files.</p>
|
295
|
-
</td>
|
296
|
-
<td class=code>
|
297
|
-
<div class='highlight'><pre> <span class="n">top</span><span class="o">.</span><span class="n">deploy</span><span class="o">.</span><span class="n">change_ownership</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>
|
298
254
|
<span class="k">end</span></pre></div>
|
299
255
|
</td>
|
300
256
|
</tr>
|
301
|
-
<tr id='section-
|
257
|
+
<tr id='section-17'>
|
302
258
|
<td class=docs>
|
303
259
|
<div class="pilwrap">
|
304
|
-
<a class="pilcrow" href="#section-
|
260
|
+
<a class="pilcrow" href="#section-17">¶</a>
|
305
261
|
</div>
|
306
262
|
<p>Tag <code>HEAD</code> with the release tag and message</p>
|
307
263
|
</td>
|
@@ -309,14 +265,13 @@ servers, tags the release and restarts the application.</p>
|
|
309
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>
|
310
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>
|
311
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>
|
312
|
-
<span class="n">top</span><span class="o">.</span><span class="n">deploy</span><span class="o">.</span><span class="n">change_ownership</span>
|
313
268
|
<span class="k">end</span></pre></div>
|
314
269
|
</td>
|
315
270
|
</tr>
|
316
|
-
<tr id='section-
|
271
|
+
<tr id='section-18'>
|
317
272
|
<td class=docs>
|
318
273
|
<div class="pilwrap">
|
319
|
-
<a class="pilcrow" href="#section-
|
274
|
+
<a class="pilcrow" href="#section-18">¶</a>
|
320
275
|
</div>
|
321
276
|
<p>After a successful deployment, the app is restarted. In the most basic deployments this does
|
322
277
|
nothing, but other recipes may override it, or attach tasks it’s before or after hooks.</p>
|
@@ -327,10 +282,10 @@ nothing, but other recipes may override it, or attach tasks it’s before or
|
|
327
282
|
<span class="k">end</span></pre></div>
|
328
283
|
</td>
|
329
284
|
</tr>
|
330
|
-
<tr id='section-
|
285
|
+
<tr id='section-19'>
|
331
286
|
<td class=docs>
|
332
287
|
<div class="pilwrap">
|
333
|
-
<a class="pilcrow" href="#section-
|
288
|
+
<a class="pilcrow" href="#section-19">¶</a>
|
334
289
|
</div>
|
335
290
|
<p>To rollback a release, the latest tag is deleted, and <code>HEAD</code> reset to the previous release
|
336
291
|
(if one exists). Finally the application is restarted again.</p>
|
@@ -350,10 +305,10 @@ nothing, but other recipes may override it, or attach tasks it’s before or
|
|
350
305
|
<span class="k">end</span></pre></div>
|
351
306
|
</td>
|
352
307
|
</tr>
|
353
|
-
<tr id='section-
|
308
|
+
<tr id='section-20'>
|
354
309
|
<td class=docs>
|
355
310
|
<div class="pilwrap">
|
356
|
-
<a class="pilcrow" href="#section-
|
311
|
+
<a class="pilcrow" href="#section-20">¶</a>
|
357
312
|
</div>
|
358
313
|
<p>In case of emergency or when manually testing deployment, it can be useful to remove all
|
359
314
|
previously deployed files before starting again.</p>
|
data/doc/lib/recap/env.html
CHANGED
@@ -13,6 +13,8 @@
|
|
13
13
|
<div id="jump_wrapper">
|
14
14
|
<div id="jump_page">
|
15
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>
|
16
18
|
<a class="source" href="bundler.html">bundler.rb</a>
|
17
19
|
<a class="source" href="capistrano_extensions.html">capistrano_extensions.rb</a>
|
18
20
|
<a class="source" href="cli.html">cli.rb</a>
|
@@ -20,6 +22,7 @@
|
|
20
22
|
<a class="source" href="deploy.html">deploy.rb</a>
|
21
23
|
<a class="source" href="env.html">env.rb</a>
|
22
24
|
<a class="source" href="foreman.html">foreman.rb</a>
|
25
|
+
<a class="source" href="namespace.html">namespace.rb</a>
|
23
26
|
<a class="source" href="preflight.html">preflight.rb</a>
|
24
27
|
<a class="source" href="rails.html">rails.rb</a>
|
25
28
|
<a class="source" href="version.html">version.rb</a>
|
@@ -48,7 +51,9 @@
|
|
48
51
|
|
49
52
|
</td>
|
50
53
|
<td class=code>
|
51
|
-
<div class='highlight'><pre><span class="
|
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
|
+
|
52
57
|
<span class="n">namespace</span> <span class="ss">:env</span> <span class="k">do</span>
|
53
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>
|
54
59
|
|
data/doc/lib/recap/foreman.html
CHANGED
@@ -13,6 +13,8 @@
|
|
13
13
|
<div id="jump_wrapper">
|
14
14
|
<div id="jump_page">
|
15
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>
|
16
18
|
<a class="source" href="bundler.html">bundler.rb</a>
|
17
19
|
<a class="source" href="capistrano_extensions.html">capistrano_extensions.rb</a>
|
18
20
|
<a class="source" href="cli.html">cli.rb</a>
|
@@ -20,6 +22,7 @@
|
|
20
22
|
<a class="source" href="deploy.html">deploy.rb</a>
|
21
23
|
<a class="source" href="env.html">env.rb</a>
|
22
24
|
<a class="source" href="foreman.html">foreman.rb</a>
|
25
|
+
<a class="source" href="namespace.html">namespace.rb</a>
|
23
26
|
<a class="source" href="preflight.html">preflight.rb</a>
|
24
27
|
<a class="source" href="rails.html">rails.rb</a>
|
25
28
|
<a class="source" href="version.html">version.rb</a>
|