1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Try and improve the 'what is' page

This commit is contained in:
Lee Hambley 2013-06-25 09:41:04 +02:00
parent bd73a5a56f
commit 59b4d8aebd
3 changed files with 587 additions and 0 deletions

View file

@ -20,3 +20,7 @@ p code, li code {
color: #222;
border-radius: 3px;
}
pre > code {
color: #FFF;
}

View file

@ -0,0 +1,436 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>What is Capistrano?</title>
<link href='http://fonts.googleapis.com/css?family=Enriqueta' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="//use.typekit.net/itm5ubu.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<link rel="stylesheet" href="/css/foundation.css" />
<link rel="stylesheet" href="/css/capistrano.css">
<link rel="stylesheet" href="/css/social_foundicons.css" />
<link rel="stylesheet" href="/css/okaidia.css">
<script src="/js/vendor/custom.modernizr.js"></script>
</head>
<body>
<script type="text/javascript">
var _gauges = _gauges || [];
(function() {
var t = document.createElement('script');
t.type = 'text/javascript';
t.async = true;
t.id = 'gauges-tracker';
t.setAttribute('data-site-id', '51c83c32613f5d7df70000bc');
t.src = '//secure.gaug.es/track.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(t, s);
})();
</script>
<script type="text/javascript">
setTimeout(function(){var a=document.createElement("script");
var b=document.getElementsByTagName("script")[0];
a.src=document.location.protocol+"//dnn506yrbagrg.cloudfront.net/pages/scripts/0017/6418.js?"+Math.floor(new Date().getTime()/3600000);
a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 1);
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-41970098-1', 'capistranorb.com');
ga('send', 'pageview');
</script>
<div class="top-bar">
<a href="/" class="brand">
<img src="/images/CapistranoLogo.png" />
</a>
</div>
<div class="row">
<div class="large-4 columns">
<ul class="side-nav">
<li><a href="http://www.harrow.io/" class="advertisment"><span class="label label-important">New</span> Hosted Capistrano for Teams</a></li>
<li class="divider"></li>
<h5>Overview</h5>
<li><a href="/documentation/overview/what-is-capistrano/">What is Capistrano?</a></li>
<li><a href="/documentation/overview/introductory-demo-video/">Introductory Demo Video</a></li>
<li class="divider"></li>
<h5>Getting Started</h5>
<li><a href="/documentation/getting-started/installation/">Installation</a></li>
<li><a href="/documentation/getting-started/preparing-your-application/">Preparing Your Application</a></li>
<li><a href="/documentation/getting-started/authentication-and-authorisation/">Authentication & Authorisation</a></li>
<li><a href="/documentation/getting-started/cold-start/">Cold Start</a></li>
<li><a href="/documentation/getting-started/rollbacks/">Rollbacks</a></li>
<li class="divider"></li>
<h5>Troubleshooting</h5>
<li><a href="/documentation/troubleshooting/authentication/">SCM (Git) Authentication</a></li>
<li><a href="/documentation/troubleshooting/connectivity/">Connectivity</a></li>
<!--<li><a href="/documentation/troubleshooting/gateway-servers/">Gateway Servers</a></li>-->
<li><a href="/documentation/troubleshooting/agent-forwarding/">Agent Forwarding</a></li>
<li><a href="/documentation/troubleshooting/sudo-password/">`sudo` Password</a></li>
<li><a href="/documentation/troubleshooting/rvm-rbenv-nvm/">RVM, `rbenv` And `nvm`</a></li>
<li class="divider"></li>
<h5>FAQ</h5>
<li><a
href="/documentation/faq/why-does-something-work-in-my-ssh-session-but-not-in-capistrano/">Why Does Something Work In An SSH Session, But Not In Capistrano?</a></li>
<li><a href="/documentation/faq/should-i-use-capistrano-to-provision-my-servers/">Should I Use Capistrano To Provision My Servers?</a></li>
<li class="divider"></li>
<h5>Power Use-Cases</h5>
<li><a href="/documentation/power-use-cases/integration-with-rake/">Integration With Rake</a></li>
<li><a href="/documentation/power-use-cases/driving-tools-such-as-chef-solo/">Driving Tools Such As <em>Chef Solo</em></a></li>
<li class="divider"></li>
<h5>Recent Announcements</h5>
<li><a href="/2013/06/01/release-announcement.html"><span class="post-date">01 Jun 2013</span> Capistrano Version 3 Release Announcement</a></li>
</ul>
</div>
<div class="large-8 column">
<div class="content">
<h2>What is Capistrano?</h2>
<h3 id="toc_0">Capistrano is a remote server automation tool.</h3>
<p>It supports the scripting and execution of arbitrary tasks, and includes a set of sane-default deployment workdflows.</p>
<p>Capistrano can be used to:</p>
<ul>
<li>Reliably deploy web application to any number of machines simultaniously,
in sequence or as a rolling set</li>
<li>To automate audits of any number of machines (checking login logs,
enumerating uptimes, and/or applying security patches)</li>
<li>To script arbitrary workflows over SSH</li>
<li>To automate common tasks in software teams.</li>
<li>To drive infrastructure provisioning tools such as <em>chef-solo</em>, <em>Ansible</em> or similar.</li>
</ul>
<p>Capistrano is also <em>very</em> scriptable, and can be integrated with any other
Ruby software to form part of a larger too.</p>
<h4 id="toc_1">What does it look like?</h4>
<div>
<pre data-line=''><code class='language-bash'>me@localhost $ cap staging deploy</code></pre>
</div>
<div>
<pre data-line class="language-capistrano"><code data-language="capistrano"><span style="color:white;">DEBUG</span> Uploading /tmp/git-ssh.sh 0%
<span style="color:#BFD4EF;"> INFO</span> Uploading /tmp/git-ssh.sh 100%
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">649ae05d</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env chmod +x /tmp/git-ssh.sh</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">649ae05d</span>] Command: <span style="color:#BFD4EF;">/usr/bin/env chmod +x /tmp/git-ssh.sh</span>
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">649ae05d</span>] Finished in 0.048 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">6a86a816</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env git ls-remote git@github.com:capistrano/rails3-bootstrap-devise-cancan.git</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">6a86a816</span>] Command: <span style="color:#BFD4EF;">( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/git-ssh.sh /usr/bin/env git ls-remote git@github.com:capistrano/rails3-bootstrap-devise-cancan.git )</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">6a86a816</span>] <span style="color:#D2EB95;"> 3419812c9f146d9a84b44bcc2c3caef94da54758 HEAD
</span><span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">6a86a816</span>] <span style="color:#D2EB95;"> 3419812c9f146d9a84b44bcc2c3caef94da54758 refs/heads/master
</span><span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">6a86a816</span>] Finished in 2.526 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">26c22cce</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env mkdir -pv /var/www/my-application/shared /var/www/my-application/releases</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">26c22cce</span>] Command: <span style="color:#BFD4EF;">/usr/bin/env mkdir -pv /var/www/my-application/shared /var/www/my-application/releases</span>
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">26c22cce</span>] Finished in 0.439 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">682cbb14</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env [ -f /var/www/my-application/repo/HEAD ]</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">682cbb14</span>] Command: <span style="color:#BFD4EF;">[ -f /var/www/my-application/repo/HEAD ]</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">682cbb14</span>] Finished in 0.448 seconds command <span style="font-weight:bold;"></span><span style="color:red;font-weight:bold;">failed</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">902d6fe6</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env if test ! -d /var/www/my-application; then echo &quot;Directory does not exist '/var/www/my-application'&quot; 1&gt;&amp;2; false; fi</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">902d6fe6</span>] Command: <span style="color:#BFD4EF;">if test ! -d /var/www/my-application; then echo &quot;Directory does not exist '/var/www/my-application'&quot; 1&gt;&amp;2; false; fi</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">902d6fe6</span>] Finished in 0.047 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">70365162</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env git clone --mirror git@github.com:capistrano/rails3-bootstrap-devise-cancan.git /var/www/my-application/repo</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">70365162</span>] Command: <span style="color:#BFD4EF;">cd /var/www/my-application &amp;&amp; ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/git-ssh.sh /usr/bin/env git clone --mirror git@github.com:capistrano/rails3-bootstrap-devise-cancan.git /var/www/my-application/repo )</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">70365162</span>] <span style="color:#D2EB95;"> Cloning into bare repository '/var/www/my-application/repo'...
</span><span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">70365162</span>] <span style="color:#D2EB95;"> remote: Counting objects: 598, done.
</span><span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">70365162</span>] Finished in 3.053 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">4d3ef555</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env if test ! -d /var/www/my-application/repo; then echo &quot;Directory does not exist '/var/www/my-application/repo'&quot; 1&gt;&amp;2; false; fi</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">4d3ef555</span>] Command: <span style="color:#BFD4EF;">if test ! -d /var/www/my-application/repo; then echo &quot;Directory does not exist '/var/www/my-application/repo'&quot; 1&gt;&amp;2; false; fi</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">4d3ef555</span>] Finished in 0.445 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">90a42e63</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env git remote update</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">90a42e63</span>] Command: <span style="color:#BFD4EF;">cd /var/www/my-application/repo &amp;&amp; /usr/bin/env git remote update</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">90a42e63</span>] <span style="color:#D2EB95;"> Fetching origin
</span><span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">90a42e63</span>] Finished in 2.078 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">39a7244f</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env if test ! -d /var/www/my-application/repo; then echo &quot;Directory does not exist '/var/www/my-application/repo'&quot; 1&gt;&amp;2; false; fi</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">39a7244f</span>] Command: <span style="color:#BFD4EF;">if test ! -d /var/www/my-application/repo; then echo &quot;Directory does not exist '/var/www/my-application/repo'&quot; 1&gt;&amp;2; false; fi</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">39a7244f</span>] Finished in 0.455 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">8665f0f1</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env git clone --branch master --depth 1 --recursive --no-hardlinks /var/www/my-application/repo /var/www/my-application/releases/20130625064744</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">8665f0f1</span>] Command: <span style="color:#BFD4EF;">cd /var/www/my-application/repo &amp;&amp; ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/git-ssh.sh /usr/bin/env git clone --branch master --depth 1 --recursive --no-hardlinks /var/www/my-application/repo /var/www/my-application/releases/20130625064744 )</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">8665f0f1</span>] <span style="color:#D2EB95;"> warning: --depth is ignored in local clones; use file:// instead.
</span><span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">8665f0f1</span>] <span style="color:#D2EB95;"> Cloning into '/var/www/my-application/releases/20130625064744'...
</span><span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">8665f0f1</span>] <span style="color:#D2EB95;"> done.
</span><span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">8665f0f1</span>] Finished in 0.141 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">bfd2d6bd</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env rm -rf /var/www/my-application/current</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">bfd2d6bd</span>] Command: <span style="color:#BFD4EF;">/usr/bin/env rm -rf /var/www/my-application/current</span>
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">bfd2d6bd</span>] Finished in 0.474 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">54ea9e57</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env ln -s /var/www/my-application/releases/20130625064744 /var/www/my-application/current</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">54ea9e57</span>] Command: <span style="color:#BFD4EF;">/usr/bin/env ln -s /var/www/my-application/releases/20130625064744 /var/www/my-application/current</span>
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">54ea9e57</span>] Finished in 0.054 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">b5af33fb</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env ls -xt /var/www/my-application/releases</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">b5af33fb</span>] Command: <span style="color:#BFD4EF;">/usr/bin/env ls -xt /var/www/my-application/releases</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">b5af33fb</span>] <span style="color:#D2EB95;"> 20130625064744
</span><span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">b5af33fb</span>] Finished in 0.445 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">10b6e05d</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env if test ! -d /var/www/my-application/releases; then echo &quot;Directory does not exist '/var/www/my-application/releases'&quot; 1&gt;&amp;2; false; fi</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">10b6e05d</span>] Command: <span style="color:#BFD4EF;">if test ! -d /var/www/my-application/releases; then echo &quot;Directory does not exist '/var/www/my-application/releases'&quot; 1&gt;&amp;2; false; fi</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">10b6e05d</span>] Finished in 0.452 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">dd6ef5b4</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env echo &quot;Branch master deployed as release 20130625064744 by leehambley; &quot; &gt;&gt; /var/www/my-application/revisions.log</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">dd6ef5b4</span>] Command: <span style="color:#BFD4EF;">echo &quot;Branch master deployed as release 20130625064744 by leehambley; &quot; &gt;&gt; /var/www/my-application/revisions.log</span>
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">dd6ef5b4</span>] Finished in 0.046 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
</code></pre>
</div>
<h4 id="toc_2">What else is in the box?</h4>
<p>There&#39;s lots of cool stuff in the Capistrano toy box:</p>
<ul>
<li>Interchangable output formatters (progress, pretty, html, etc)</li>
<li>Easy to add support for other source control management software.</li>
<li>A rudimentary multi-console for running Capistrano interactively.</li>
<li>Host and Role filters for partial deploys, or partial-cluster maintenance.</li>
<li>Recipes for the Rails asset pipelines, and database migrations.</li>
<li>Support for complex environments.</li>
<li>A sane, expressive API:</li>
</ul>
<div>
<pre data-line=''><code class='language-ruby'>desc &quot;Show off the API&quot;
task :ditty do
on roles(:all) do |host|
# Capture output from the remote host, and re-use it
# we can reflect on the `host` object passed to the block
# and use the `info` logger method to benefit from the
# output formatter that is selected.
uptime = capture(&#39;uptime&#39;)
if host.roles.include?(:web)
info &quot;Your webserver #{host} has uptime: #{uptime}&quot;
end
end
on roles(:app) do
# We can set environmental varaibles for the duration of a block
# and move the process into a directoy, executing arbitrary tasks
# such as letting Rails do some heavy lifting.
with({:rails_env =&gt; :production}) do
within(&#39;/var/www/my/rails/app&#39;) do
execute :rails, :runner, &#39;MyModel.something&#39;
end
end
end
on roles(:db) do
# We can even switch users, provided we have support on the remote
# server for switching to that user without being prompted for a
# passphrase.
as &#39;postgres&#39; do
widgets = capture &quot;echo &#39;SELECT * FROM widgets;&#39; | psql my_database&quot;
if widgets.to_i &lt; 50
warn &quot;There are fewer than 50 widgets in the database on #{host}!&quot;
end
end
end
on roles(:all) do
# We can even use `test` the way the Unix gods intended
if test(&quot;[ -d /some/directory ]&quot;)
info &quot;Phew, it&#39;s ok, the directory exists!&quot;
end
end
end</code></pre>
</div>
</div>
</div>
</div>
<!--<div class="container"> -->
<!-- <h1 class="title"><a href="/">Capistrano</a></h1>-->
<!-- <a class="extra" href="/">home</a> -->
<!-- </div> -->
<!-- <h3 id="toc_0">Capistrano is a remote server automation tool.</h3>
<p>It supports the scripting and execution of arbitrary tasks, and includes a set of sane-default deployment workdflows.</p>
<p>Capistrano can be used to:</p>
<ul>
<li>Reliably deploy web application to any number of machines simultaniously,
in sequence or as a rolling set</li>
<li>To automate audits of any number of machines (checking login logs,
enumerating uptimes, and/or applying security patches)</li>
<li>To script arbitrary workflows over SSH</li>
<li>To automate common tasks in software teams.</li>
<li>To drive infrastructure provisioning tools such as <em>chef-solo</em>, <em>Ansible</em> or similar.</li>
</ul>
<p>Capistrano is also <em>very</em> scriptable, and can be integrated with any other
Ruby software to form part of a larger too.</p>
<h4 id="toc_1">What does it look like?</h4>
<div>
<pre data-line=''><code class='language-bash'>me@localhost $ cap staging deploy</code></pre>
</div>
<div>
<pre data-line class="language-capistrano"><code data-language="capistrano"><span style="color:white;">DEBUG</span> Uploading /tmp/git-ssh.sh 0%
<span style="color:#BFD4EF;"> INFO</span> Uploading /tmp/git-ssh.sh 100%
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">649ae05d</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env chmod +x /tmp/git-ssh.sh</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">649ae05d</span>] Command: <span style="color:#BFD4EF;">/usr/bin/env chmod +x /tmp/git-ssh.sh</span>
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">649ae05d</span>] Finished in 0.048 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">6a86a816</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env git ls-remote git@github.com:capistrano/rails3-bootstrap-devise-cancan.git</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">6a86a816</span>] Command: <span style="color:#BFD4EF;">( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/git-ssh.sh /usr/bin/env git ls-remote git@github.com:capistrano/rails3-bootstrap-devise-cancan.git )</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">6a86a816</span>] <span style="color:#D2EB95;"> 3419812c9f146d9a84b44bcc2c3caef94da54758 HEAD
</span><span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">6a86a816</span>] <span style="color:#D2EB95;"> 3419812c9f146d9a84b44bcc2c3caef94da54758 refs/heads/master
</span><span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">6a86a816</span>] Finished in 2.526 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">26c22cce</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env mkdir -pv /var/www/my-application/shared /var/www/my-application/releases</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">26c22cce</span>] Command: <span style="color:#BFD4EF;">/usr/bin/env mkdir -pv /var/www/my-application/shared /var/www/my-application/releases</span>
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">26c22cce</span>] Finished in 0.439 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">682cbb14</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env [ -f /var/www/my-application/repo/HEAD ]</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">682cbb14</span>] Command: <span style="color:#BFD4EF;">[ -f /var/www/my-application/repo/HEAD ]</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">682cbb14</span>] Finished in 0.448 seconds command <span style="font-weight:bold;"></span><span style="color:red;font-weight:bold;">failed</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">902d6fe6</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env if test ! -d /var/www/my-application; then echo &quot;Directory does not exist '/var/www/my-application'&quot; 1&gt;&amp;2; false; fi</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">902d6fe6</span>] Command: <span style="color:#BFD4EF;">if test ! -d /var/www/my-application; then echo &quot;Directory does not exist '/var/www/my-application'&quot; 1&gt;&amp;2; false; fi</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">902d6fe6</span>] Finished in 0.047 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">70365162</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env git clone --mirror git@github.com:capistrano/rails3-bootstrap-devise-cancan.git /var/www/my-application/repo</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">70365162</span>] Command: <span style="color:#BFD4EF;">cd /var/www/my-application &amp;&amp; ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/git-ssh.sh /usr/bin/env git clone --mirror git@github.com:capistrano/rails3-bootstrap-devise-cancan.git /var/www/my-application/repo )</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">70365162</span>] <span style="color:#D2EB95;"> Cloning into bare repository '/var/www/my-application/repo'...
</span><span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">70365162</span>] <span style="color:#D2EB95;"> remote: Counting objects: 598, done.
</span><span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">70365162</span>] Finished in 3.053 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">4d3ef555</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env if test ! -d /var/www/my-application/repo; then echo &quot;Directory does not exist '/var/www/my-application/repo'&quot; 1&gt;&amp;2; false; fi</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">4d3ef555</span>] Command: <span style="color:#BFD4EF;">if test ! -d /var/www/my-application/repo; then echo &quot;Directory does not exist '/var/www/my-application/repo'&quot; 1&gt;&amp;2; false; fi</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">4d3ef555</span>] Finished in 0.445 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">90a42e63</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env git remote update</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">90a42e63</span>] Command: <span style="color:#BFD4EF;">cd /var/www/my-application/repo &amp;&amp; /usr/bin/env git remote update</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">90a42e63</span>] <span style="color:#D2EB95;"> Fetching origin
</span><span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">90a42e63</span>] Finished in 2.078 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">39a7244f</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env if test ! -d /var/www/my-application/repo; then echo &quot;Directory does not exist '/var/www/my-application/repo'&quot; 1&gt;&amp;2; false; fi</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">39a7244f</span>] Command: <span style="color:#BFD4EF;">if test ! -d /var/www/my-application/repo; then echo &quot;Directory does not exist '/var/www/my-application/repo'&quot; 1&gt;&amp;2; false; fi</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">39a7244f</span>] Finished in 0.455 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">8665f0f1</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env git clone --branch master --depth 1 --recursive --no-hardlinks /var/www/my-application/repo /var/www/my-application/releases/20130625064744</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">8665f0f1</span>] Command: <span style="color:#BFD4EF;">cd /var/www/my-application/repo &amp;&amp; ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/git-ssh.sh /usr/bin/env git clone --branch master --depth 1 --recursive --no-hardlinks /var/www/my-application/repo /var/www/my-application/releases/20130625064744 )</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">8665f0f1</span>] <span style="color:#D2EB95;"> warning: --depth is ignored in local clones; use file:// instead.
</span><span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">8665f0f1</span>] <span style="color:#D2EB95;"> Cloning into '/var/www/my-application/releases/20130625064744'...
</span><span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">8665f0f1</span>] <span style="color:#D2EB95;"> done.
</span><span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">8665f0f1</span>] Finished in 0.141 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">bfd2d6bd</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env rm -rf /var/www/my-application/current</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">bfd2d6bd</span>] Command: <span style="color:#BFD4EF;">/usr/bin/env rm -rf /var/www/my-application/current</span>
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">bfd2d6bd</span>] Finished in 0.474 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">54ea9e57</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env ln -s /var/www/my-application/releases/20130625064744 /var/www/my-application/current</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">54ea9e57</span>] Command: <span style="color:#BFD4EF;">/usr/bin/env ln -s /var/www/my-application/releases/20130625064744 /var/www/my-application/current</span>
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">54ea9e57</span>] Finished in 0.054 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">b5af33fb</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env ls -xt /var/www/my-application/releases</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">b5af33fb</span>] Command: <span style="color:#BFD4EF;">/usr/bin/env ls -xt /var/www/my-application/releases</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">b5af33fb</span>] <span style="color:#D2EB95;"> 20130625064744
</span><span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">b5af33fb</span>] Finished in 0.445 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">10b6e05d</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env if test ! -d /var/www/my-application/releases; then echo &quot;Directory does not exist '/var/www/my-application/releases'&quot; 1&gt;&amp;2; false; fi</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">10b6e05d</span>] Command: <span style="color:#BFD4EF;">if test ! -d /var/www/my-application/releases; then echo &quot;Directory does not exist '/var/www/my-application/releases'&quot; 1&gt;&amp;2; false; fi</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">10b6e05d</span>] Finished in 0.452 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">dd6ef5b4</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env echo &quot;Branch master deployed as release 20130625064744 by leehambley; &quot; &gt;&gt; /var/www/my-application/revisions.log</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">dd6ef5b4</span>] Command: <span style="color:#BFD4EF;">echo &quot;Branch master deployed as release 20130625064744 by leehambley; &quot; &gt;&gt; /var/www/my-application/revisions.log</span>
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">dd6ef5b4</span>] Finished in 0.046 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
</code></pre>
</div>
<h4 id="toc_2">What else is in the box?</h4>
<p>There&#39;s lots of cool stuff in the Capistrano toy box:</p>
<ul>
<li>Interchangable output formatters (progress, pretty, html, etc)</li>
<li>Easy to add support for other source control management software.</li>
<li>A rudimentary multi-console for running Capistrano interactively.</li>
<li>Host and Role filters for partial deploys, or partial-cluster maintenance.</li>
<li>Recipes for the Rails asset pipelines, and database migrations.</li>
<li>Support for complex environments.</li>
<li>A sane, expressive API:</li>
</ul>
<div>
<pre data-line=''><code class='language-ruby'>desc &quot;Show off the API&quot;
task :ditty do
on roles(:all) do |host|
# Capture output from the remote host, and re-use it
# we can reflect on the `host` object passed to the block
# and use the `info` logger method to benefit from the
# output formatter that is selected.
uptime = capture(&#39;uptime&#39;)
if host.roles.include?(:web)
info &quot;Your webserver #{host} has uptime: #{uptime}&quot;
end
end
on roles(:app) do
# We can set environmental varaibles for the duration of a block
# and move the process into a directoy, executing arbitrary tasks
# such as letting Rails do some heavy lifting.
with({:rails_env =&gt; :production}) do
within(&#39;/var/www/my/rails/app&#39;) do
execute :rails, :runner, &#39;MyModel.something&#39;
end
end
end
on roles(:db) do
# We can even switch users, provided we have support on the remote
# server for switching to that user without being prompted for a
# passphrase.
as &#39;postgres&#39; do
widgets = capture &quot;echo &#39;SELECT * FROM widgets;&#39; | psql my_database&quot;
if widgets.to_i &lt; 50
warn &quot;There are fewer than 50 widgets in the database on #{host}!&quot;
end
end
end
on roles(:all) do
# We can even use `test` the way the Unix gods intended
if test(&quot;[ -d /some/directory ]&quot;)
info &quot;Phew, it&#39;s ok, the directory exists!&quot;
end
end
end</code></pre>
</div>
-->
<!--</div> [> /container <] -->
<div class="row">
<div class="large-4 columns">
<ul>
<li><a href="/about">About Capistrano</a></li>
<li><a href="https://github.com/capistrano/capistrano/blob/master/CONTRIBUTING">Contributing</a></li>
<li><a href="https://rubygems.org/gems/capistrano/versions">Releases</a></li>
<li><a href="/upgrading">Upgrading</a></li>
<li><a href="/security">Security</a></li>
</ul>
</div>
<div class="large-4 columns">
<ul>
<li><a href="http://stackoverflow.com/questions/tagged/capistrano">StackOverflow</a></li>
<li><a href="https://groups.google.com/forum/#!forum/capistrano">Mailing List</a></li>
<li><a href=".... ">Commercial Support</a></li>
</ul>
</div>
<div class="large-4 columns">
<ul>
<li><a href="//twitter.com/capistranorb"><i class="foundicon-twitter"></i></a></li>
<li><a href="//github.com/capistrano"><i class="foundicon-github"></i></a></li>
</ul>
</div>
</div>
<script src="/js/prism.js"></script>
<script src="/js/prism.ruby.js"></script>
</body>
</html>

View file

@ -0,0 +1,147 @@
---
title: What is Capistrano?
layout: default
---
### Capistrano is a remote server automation tool.
It supports the scripting and execution of arbitrary tasks, and includes a set of sane-default deployment workdflows.
Capistrano can be used to:
* Reliably deploy web application to any number of machines simultaniously,
in sequence or as a rolling set
* To automate audits of any number of machines (checking login logs,
enumerating uptimes, and/or applying security patches)
* To script arbitrary workflows over SSH
* To automate common tasks in software teams.
* To drive infrastructure provisioning tools such as *chef-solo*, *Ansible* or similar.
Capistrano is also *very* scriptable, and can be integrated with any other
Ruby software to form part of a larger too.
#### What does it look like?
{% prism bash %}
me@localhost $ cap staging deploy
{% endprism %}
<div>
<pre data-line class="language-capistrano"><code data-language="capistrano"><span style="color:white;">DEBUG</span> Uploading /tmp/git-ssh.sh 0%
<span style="color:#BFD4EF;"> INFO</span> Uploading /tmp/git-ssh.sh 100%
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">649ae05d</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env chmod +x /tmp/git-ssh.sh</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">649ae05d</span>] Command: <span style="color:#BFD4EF;">/usr/bin/env chmod +x /tmp/git-ssh.sh</span>
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">649ae05d</span>] Finished in 0.048 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">6a86a816</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env git ls-remote git@github.com:capistrano/rails3-bootstrap-devise-cancan.git</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">6a86a816</span>] Command: <span style="color:#BFD4EF;">( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/git-ssh.sh /usr/bin/env git ls-remote git@github.com:capistrano/rails3-bootstrap-devise-cancan.git )</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">6a86a816</span>] <span style="color:#D2EB95;"> 3419812c9f146d9a84b44bcc2c3caef94da54758 HEAD
</span><span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">6a86a816</span>] <span style="color:#D2EB95;"> 3419812c9f146d9a84b44bcc2c3caef94da54758 refs/heads/master
</span><span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">6a86a816</span>] Finished in 2.526 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">26c22cce</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env mkdir -pv /var/www/my-application/shared /var/www/my-application/releases</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">26c22cce</span>] Command: <span style="color:#BFD4EF;">/usr/bin/env mkdir -pv /var/www/my-application/shared /var/www/my-application/releases</span>
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">26c22cce</span>] Finished in 0.439 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">682cbb14</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env [ -f /var/www/my-application/repo/HEAD ]</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">682cbb14</span>] Command: <span style="color:#BFD4EF;">[ -f /var/www/my-application/repo/HEAD ]</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">682cbb14</span>] Finished in 0.448 seconds command <span style="font-weight:bold;"></span><span style="color:red;font-weight:bold;">failed</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">902d6fe6</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env if test ! -d /var/www/my-application; then echo &quot;Directory does not exist '/var/www/my-application'&quot; 1&gt;&amp;2; false; fi</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">902d6fe6</span>] Command: <span style="color:#BFD4EF;">if test ! -d /var/www/my-application; then echo &quot;Directory does not exist '/var/www/my-application'&quot; 1&gt;&amp;2; false; fi</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">902d6fe6</span>] Finished in 0.047 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">70365162</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env git clone --mirror git@github.com:capistrano/rails3-bootstrap-devise-cancan.git /var/www/my-application/repo</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">70365162</span>] Command: <span style="color:#BFD4EF;">cd /var/www/my-application &amp;&amp; ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/git-ssh.sh /usr/bin/env git clone --mirror git@github.com:capistrano/rails3-bootstrap-devise-cancan.git /var/www/my-application/repo )</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">70365162</span>] <span style="color:#D2EB95;"> Cloning into bare repository '/var/www/my-application/repo'...
</span><span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">70365162</span>] <span style="color:#D2EB95;"> remote: Counting objects: 598, done.
</span><span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">70365162</span>] Finished in 3.053 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">4d3ef555</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env if test ! -d /var/www/my-application/repo; then echo &quot;Directory does not exist '/var/www/my-application/repo'&quot; 1&gt;&amp;2; false; fi</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">4d3ef555</span>] Command: <span style="color:#BFD4EF;">if test ! -d /var/www/my-application/repo; then echo &quot;Directory does not exist '/var/www/my-application/repo'&quot; 1&gt;&amp;2; false; fi</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">4d3ef555</span>] Finished in 0.445 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">90a42e63</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env git remote update</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">90a42e63</span>] Command: <span style="color:#BFD4EF;">cd /var/www/my-application/repo &amp;&amp; /usr/bin/env git remote update</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">90a42e63</span>] <span style="color:#D2EB95;"> Fetching origin
</span><span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">90a42e63</span>] Finished in 2.078 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">39a7244f</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env if test ! -d /var/www/my-application/repo; then echo &quot;Directory does not exist '/var/www/my-application/repo'&quot; 1&gt;&amp;2; false; fi</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">39a7244f</span>] Command: <span style="color:#BFD4EF;">if test ! -d /var/www/my-application/repo; then echo &quot;Directory does not exist '/var/www/my-application/repo'&quot; 1&gt;&amp;2; false; fi</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">39a7244f</span>] Finished in 0.455 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">8665f0f1</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env git clone --branch master --depth 1 --recursive --no-hardlinks /var/www/my-application/repo /var/www/my-application/releases/20130625064744</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">8665f0f1</span>] Command: <span style="color:#BFD4EF;">cd /var/www/my-application/repo &amp;&amp; ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/git-ssh.sh /usr/bin/env git clone --branch master --depth 1 --recursive --no-hardlinks /var/www/my-application/repo /var/www/my-application/releases/20130625064744 )</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">8665f0f1</span>] <span style="color:#D2EB95;"> warning: --depth is ignored in local clones; use file:// instead.
</span><span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">8665f0f1</span>] <span style="color:#D2EB95;"> Cloning into '/var/www/my-application/releases/20130625064744'...
</span><span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">8665f0f1</span>] <span style="color:#D2EB95;"> done.
</span><span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">8665f0f1</span>] Finished in 0.141 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">bfd2d6bd</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env rm -rf /var/www/my-application/current</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">bfd2d6bd</span>] Command: <span style="color:#BFD4EF;">/usr/bin/env rm -rf /var/www/my-application/current</span>
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">bfd2d6bd</span>] Finished in 0.474 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">54ea9e57</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env ln -s /var/www/my-application/releases/20130625064744 /var/www/my-application/current</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">54ea9e57</span>] Command: <span style="color:#BFD4EF;">/usr/bin/env ln -s /var/www/my-application/releases/20130625064744 /var/www/my-application/current</span>
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">54ea9e57</span>] Finished in 0.054 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">b5af33fb</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env ls -xt /var/www/my-application/releases</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">b5af33fb</span>] Command: <span style="color:#BFD4EF;">/usr/bin/env ls -xt /var/www/my-application/releases</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">b5af33fb</span>] <span style="color:#D2EB95;"> 20130625064744
</span><span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">b5af33fb</span>] Finished in 0.445 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">10b6e05d</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env if test ! -d /var/www/my-application/releases; then echo &quot;Directory does not exist '/var/www/my-application/releases'&quot; 1&gt;&amp;2; false; fi</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">10b6e05d</span>] Command: <span style="color:#BFD4EF;">if test ! -d /var/www/my-application/releases; then echo &quot;Directory does not exist '/var/www/my-application/releases'&quot; 1&gt;&amp;2; false; fi</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">10b6e05d</span>] Finished in 0.452 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">dd6ef5b4</span>] Running <span style="color:olive;"></span><span style="color:olive;font-weight:bold;">/usr/bin/env echo &quot;Branch master deployed as release 20130625064744 by leehambley; &quot; &gt;&gt; /var/www/my-application/revisions.log</span> on <span style="color:#BFD4EF;">example.com</span>
<span style="color:white;">DEBUG</span> [<span style="color:#D2EB95;">dd6ef5b4</span>] Command: <span style="color:#BFD4EF;">echo &quot;Branch master deployed as release 20130625064744 by leehambley; &quot; &gt;&gt; /var/www/my-application/revisions.log</span>
<span style="color:#BFD4EF;"> INFO</span> [<span style="color:#D2EB95;">dd6ef5b4</span>] Finished in 0.046 seconds command <span style="font-weight:bold;"></span><span style="color:#D2EB95;font-weight:bold;">successful</span>.
</code></pre>
</div>
#### What else is in the box?
There's lots of cool stuff in the Capistrano toy box:
* Interchangable output formatters (progress, pretty, html, etc)
* Easy to add support for other source control management software.
* A rudimentary multi-console for running Capistrano interactively.
* Host and Role filters for partial deploys, or partial-cluster maintenance.
* Recipes for the Rails asset pipelines, and database migrations.
* Support for complex environments.
* A sane, expressive API:
{% prism ruby %}
desc "Show off the API"
task :ditty do
on roles(:all) do |host|
# Capture output from the remote host, and re-use it
# we can reflect on the `host` object passed to the block
# and use the `info` logger method to benefit from the
# output formatter that is selected.
uptime = capture('uptime')
if host.roles.include?(:web)
info "Your webserver #{host} has uptime: #{uptime}"
end
end
on roles(:app) do
# We can set environmental varaibles for the duration of a block
# and move the process into a directoy, executing arbitrary tasks
# such as letting Rails do some heavy lifting.
with({:rails_env => :production}) do
within('/var/www/my/rails/app') do
execute :rails, :runner, 'MyModel.something'
end
end
end
on roles(:db) do
# We can even switch users, provided we have support on the remote
# server for switching to that user without being prompted for a
# passphrase.
as 'postgres' do
widgets = capture "echo 'SELECT * FROM widgets;' | psql my_database"
if widgets.to_i < 50
warn "There are fewer than 50 widgets in the database on #{host}!"
end
end
end
on roles(:all) do
# We can even use `test` the way the Unix gods intended
if test("[ -d /some/directory ]")
info "Phew, it's ok, the directory exists!"
end
end
end
{% endprism %}