<?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>Reinventar &#187; capistrano</title>
	<atom:link href="http://reinventar.com/tag/capistrano/feed/" rel="self" type="application/rss+xml" />
	<link>http://reinventar.com</link>
	<description></description>
	<lastBuildDate>Tue, 05 Apr 2011 13:25:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Setting up GIT and Passenger with Capistrano</title>
		<link>http://reinventar.com/2008/09/10/setting-up-git-and-passenger-with-capistrano/</link>
		<comments>http://reinventar.com/2008/09/10/setting-up-git-and-passenger-with-capistrano/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 10:06:06 +0000</pubDate>
		<dc:creator>Pedro Sousa</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[passenger]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://reinventar.com/?p=313</guid>
		<description><![CDATA[This week I needed to get Capistrano working with GIT because I moved some of my Ruby on Rails projects from SVN to GITHUB and I Capistrano garantees a easy deployment solution. There&#8217;s plenty of information out there about GIT, you can find plenty of guides at github and some videos at Railscasts and GitCasts. [...]]]></description>
			<content:encoded><![CDATA[<p>This week I needed to get Capistrano working with GIT because I moved some of my <a href="http://www.rubyonrails.org" target="_blank">Ruby on Rails</a> projects from SVN to <a href="http://www.github.com" target="_blank">GITHUB</a> and I Capistrano garantees a easy deployment solution.</p>
<p>There&#8217;s plenty of information out there about GIT, you can find plenty of guides at github and some videos at <a href="http://railscasts.com/episodes/96-git-on-rails" target="_blank">Railscasts</a> and <a href="http://www.gitcasts.com/" target="_blank">GitCasts</a>.</p>
<p>So, first of all, GIT needs to be installed on the server running my apps, so I had to run these steps to get it working</p>
<pre lang="Bash">sudo apt-get install libexpat1-dev zlibc curl gettext

sudo apt-get install libcurl3-openssl-dev

cd ~/src
wget http://www.kernel.org/pub/software/scm/git/git-1.5.4.rc2.tar.gz

gunzip git-1.5.4.rc2.tar.gz
tar xvf git-1.5.4.rc2.tar

cd git-1.5.4.rc2
make prefix=/usr/local all
sudo make prefix=/usr/local install</pre>
<p>So what this does is install a bunch of stuff needed for Git, including Curl and finally I compile Git. I didn&#8217;t advance more because I only need it to pull and clone stuff.</p>
<p>Next is the capistrano recipe for MyDumbApp:</p>
<pre lang="ruby">set :application, "myDumbApp"
set :deploy_to, "/home/myserveuserarea/apps/#{application}"
#############################################################
#	Settings
#############################################################

default_run_options[:pty] = true
set :use_sudo, true

#############################################################
#	Servers
#############################################################

set :user, "myserveruser"
set :domain, "154.14.13.12"
server domain, :app, :web
role :db, domain, :primary =&gt; true
set :runner, "myserveruser"

#############################################################
#	GIT
#############################################################

set :repository,  "git@github.com:reinventar/mydumbapp.git"
set :scm, "git"
set :scm_passphrase, "passwordforgituser" #This is your custom github user password
ssh_options[:forward_agent] = true
set :branch, "master"

#############################################################
#	Passenger
#############################################################

namespace :deploy do
  desc "Restarting mod_rails with restart.txt"
  task :restart, :roles =&gt; :app, :except =&gt; { :no_release =&gt; true } do
    run "touch #{current_path}/tmp/restart.txt"
  end

  [:start, :stop].each do |t|
    desc "#{t} task is a no-op with mod_rails"
    task t, :roles =&gt; :app do ; end
  end
end</pre>
<p>Just a few notes about this recipe:</p>
<p>I&#8217;m using this with a repository in GitHub, I assume you already have your local machine configured, if not here&#8217;s some pretty useful guides.</p>
<p>I think it&#8217;s best to make sure you have the latest capistrano version installed on your local machine.</p>
<p>With the latest version of Capistrano, you need to add</p>
<pre lang="ruby">set :runner, "myserveruser"</pre>
<p>and repeat your remote server username or else you&#8217;ll get a nasty error.</p>
<p>ssh_options[:forward_agent] = true is used so that you can use your private key stored in your local machine remotely, but first I think you need to do something like this:</p>
<pre lang="bash">cd .ssh
ssh-add githubkey</pre>
<p>to add the key to your ssh-agent.</p>
<p>I&#8217;m using <a href="http://www.modrails.com/" target="_blank">Passenger</a> for my apps, so that last part of the recipe is intended to restart my application, if you&#8217;re using mongrel or something else, you&#8217;ll need to tell Capistrano how to restart your application.</p>
<p>And that&#8217;s it. Hope it works. <img onError="javascript: wp_404_images_fix = window.wp_404_images_fix || function(){}; wp_404_images_fix(this);"  src='http://reinventar.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If you have a better or alternative way to deploy, advice, etc, why not share it here?</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://reinventar.com/2011/03/04/install-git-on-centos-5/" rel="bookmark" class="crp_title">Install GIT on CENTOS 5</a></li><li><a href="http://reinventar.com/2011/03/04/install-imagemagick-on-centos-5-5/" rel="bookmark" class="crp_title">Install Imagemagick on Centos 5.5</a></li><li><a href="http://reinventar.com/2011/04/05/install-imagemagick-on-ubuntu-with-delegates/" rel="bookmark" class="crp_title">Install Imagemagick on Ubuntu with delegates</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://reinventar.com/2008/09/10/setting-up-git-and-passenger-with-capistrano/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

