<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>michael pardo &#187; Ruby</title>
	<atom:link href="http://michaelpardo.com/category/development/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://michaelpardo.com</link>
	<description>software developer</description>
	<lastBuildDate>Fri, 14 May 2010 13:21:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=8294</generator>
		<item>
		<title>Easy Ruby on Rails Deployment with Capistrano and Passenger</title>
		<link>http://michaelpardo.com/2009/06/easy-ruby-on-rails-deployment-with-capistrano-and-passenger/</link>
		<comments>http://michaelpardo.com/2009/06/easy-ruby-on-rails-deployment-with-capistrano-and-passenger/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 15:03:13 +0000</pubDate>
		<dc:creator>Michael Pardo</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://michaelpardo.com/?p=135</guid>
		<description><![CDATA[Let&#8217;s start off with a few aliases that speed things up. The commands are pretty self explanatory. I&#8217;ve got my deployment down to a simple acd command, which will add and commit to svn, then deploy to the server. To add a migration before deployment I use acmd. The following commands go into your ~/.bash_login [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s start off with a few aliases that speed things up. The commands are pretty self explanatory. I&#8217;ve got my deployment down to a simple <strong>acd</strong> command, which will add and commit to svn, then deploy to the server. To add a migration before deployment I use <strong>acmd</strong>. The following commands go into your <strong>~/.bash_login</strong> file (assuming you&#8217;re using OS X or Linux).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">svna</span>=<span style="color: #ff0000;">'svn add * --force'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">svnc</span>=<span style="color: #ff0000;">'svn commit . -m &quot;&quot;'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">capd</span>=<span style="color: #ff0000;">'cap deploy'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">capm</span>=<span style="color: #ff0000;">'cap deploy:migrate'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">acd</span>=<span style="color: #ff0000;">'svna; svnc; capd;'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">acmd</span>=<span style="color: #ff0000;">'svna; svnc; capm; capd;'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">rors</span>=<span style="color: #ff0000;">'script/server -b localhost'</span></pre></td></tr></table></div>

<p>If you don&#8217;t already have capistrano setup, it&#8217;s as easy as</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ gem <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-y</span> capistrano</pre></td></tr></table></div>

<p>When I first setup an new rails project I follow these steps</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ rails <span style="color: #660033;">-d</span> mysql PROJECT_NAME
$ <span style="color: #7a0874; font-weight: bold;">cd</span> PROJECT_NAME
$ capify .
$ <span style="color: #c20cb9; font-weight: bold;">svn</span> import PROJECT_PATH SVN_PATH <span style="color: #660033;">-m</span> <span style="color: #ff0000;">'Initial import'</span>
$ <span style="color: #7a0874; font-weight: bold;">cd</span> ..
$ <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-Rf</span> PROJECT_PATH
$ <span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> SVN_PATH
$ mate PROJECT_PATH</pre></td></tr></table></div>

<p>This initial setup process will create the rails project, setup Capistrano, add it to svn, and open it in TextMate. You can of course leave that last line out and use any IDE you wish.</p>
<p>Next open the <strong>config/deploy.rb</strong> file that Capistrano created for you. This is where you will put all your Capistrano instructions:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">set <span style="color:#ff3333; font-weight:bold;">:user</span>, <span style="color:#996600;">&quot;SUDO_USER&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:password</span>, <span style="color:#996600;">&quot;SUDO_USER_PASS&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:domain</span>, <span style="color:#996600;">&quot;example.com&quot;</span>
server domain, <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#ff3333; font-weight:bold;">:web</span>
role <span style="color:#ff3333; font-weight:bold;">:db</span>, domain, <span style="color:#ff3333; font-weight:bold;">:primary</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>
&nbsp;
set <span style="color:#ff3333; font-weight:bold;">:application</span>, <span style="color:#996600;">&quot;example&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:deploy_to</span>, <span style="color:#996600;">&quot;/home/example/public_html/#{application}.sandbox.#{domain}/#{application}/&quot;</span>
&nbsp;
default_run_options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:pty</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
set <span style="color:#ff3333; font-weight:bold;">:use_sudo</span>, <span style="color:#0000FF; font-weight:bold;">true</span>
set <span style="color:#ff3333; font-weight:bold;">:runner</span>, <span style="color:#ff3333; font-weight:bold;">:user</span>
&nbsp;
set <span style="color:#ff3333; font-weight:bold;">:repository</span>,  <span style="color:#996600;">&quot;http://#{domain}/svn/#{application}&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:scm_username</span>, <span style="color:#996600;">&quot;SVN_USER&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:scm_password</span>, <span style="color:#996600;">&quot;SVN_USER_PASS&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:checkout</span>, <span style="color:#996600;">&quot;export&quot;</span>
&nbsp;
namespace <span style="color:#ff3333; font-weight:bold;">:deploy</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  desc <span style="color:#996600;">&quot;Restart Application&quot;</span>
  task <span style="color:#ff3333; font-weight:bold;">:restart</span>, <span style="color:#ff3333; font-weight:bold;">:roles</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:app</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    run <span style="color:#996600;">&quot;touch #{current_path}/tmp/restart.txt&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>Just change all the capitalized tokens to reflect your own settings. Then deploying should be as simple as typing <strong>acd</strong> in the Terminal. I created a blank file at <strong>/tmp/restart.txt</strong> and added it to svn so passenger will restart the rails app when you deploy. Also, you may not want to put your sudo password into <strong>deploy.rb</strong>.</p>
<p>I entountered various struggles in getting everything to work correctly. If you need help with something specific, post it in a comment. I can probably tell you what the problem is.</p>
<p>You can find help for Passenger here: <a href="http://www.modrails.com/">http://www.modrails.com/</a> and help for Capistrano here: <a href="http://www.capify.org/">http://www.capify.org/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://michaelpardo.com/2009/06/easy-ruby-on-rails-deployment-with-capistrano-and-passenger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
