<?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"
	>

<channel>
	<title>ne•o•phil•i•ac</title>
	<atom:link href="http://www.neophiliac.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.neophiliac.net</link>
	<description>noun : addicted to all things new and novel</description>
	<pubDate>Wed, 03 Sep 2008 23:27:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>rubybroker-ec2 and Merb 0.9.5</title>
		<link>http://www.neophiliac.net/2008/09/03/rubybroker-ec2-and-merb-095/</link>
		<comments>http://www.neophiliac.net/2008/09/03/rubybroker-ec2-and-merb-095/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 23:25:38 +0000</pubDate>
		<dc:creator>michael.daniel.jones</dc:creator>
		
		<category><![CDATA[capistrano]]></category>

		<category><![CDATA[merb]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[rubybroker-ec2]]></category>

		<guid isPermaLink="false">http://www.neophiliac.net/?p=78</guid>
		<description><![CDATA[Whilst I was putting together rubybroker-ec2 Merb 0.9.5 was released, as my side project was running 0.9.4 I fixed to use that version. This afternoon on my train journey home I finally upgraded, when it came to deploy it turned out different configuration is required for 0.9.5. 
This release addresses the issues around this and [...]]]></description>
			<content:encoded><![CDATA[<p>Whilst I was putting together rubybroker-ec2 Merb 0.9.5 was released, as my <a href="http://www.we-workout.com">side project</a> was running 0.9.4 I fixed to use that version. This afternoon on my train journey home I finally upgraded, when it came to deploy it turned out different configuration is required for 0.9.5. </p>
<p>This release addresses the issues around this and also allows you to specify the version of Merb your application is using so the appropriate dependencies are installed.</p>
<p>You can grab the new version from GitHub:</p>
<pre name="code">  $ gem sources -a http://gems.github.com
  $ sudo gem install mikejones-rubybroker-ec2
</pre>
<p>The deployment process in the same as before but now when you now bootstrap your instance Merb 0.9.5 will be installed. This can be overridden in you deploy.rb e.g.: </p>
<pre name="code" class="ruby:nocontrols:nogutter">  set :merb_version, "0.9.3"</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.neophiliac.net/2008/09/03/rubybroker-ec2-and-merb-095/feed/</wfw:commentRss>
		</item>
		<item>
		<title>rubybroker-ec2: Easy deployment to Phusion Passenger on Amazon EC2</title>
		<link>http://www.neophiliac.net/2008/08/31/rubybroker-ec2-easy-deployment-to-phusion-passenger-on-amazon-ec2/</link>
		<comments>http://www.neophiliac.net/2008/08/31/rubybroker-ec2-easy-deployment-to-phusion-passenger-on-amazon-ec2/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 16:58:10 +0000</pubDate>
		<dc:creator>michael.daniel.jones</dc:creator>
		
		<category><![CDATA[capistrano]]></category>

		<category><![CDATA[merb]]></category>

		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.neophiliac.net/?p=63</guid>
		<description><![CDATA[
      rubybroker-ec2 is a collection of Capistrano recipes geared towards getting Merb applications live on the internet with minutes. It utilizes Amazon’s Elastic Compute Cloud (EC2) and the Apache module Phusion Passenger to give you a straightforward, automated, and repeatable deployment process.
    

     [...]]]></description>
			<content:encoded><![CDATA[<p>
      <a href="http://github.com/mikejones/rubybroker-ec2">rubybroker-ec2</a> is a collection of Capistrano recipes geared towards getting Merb applications live on the internet with minutes. It utilizes Amazon’s Elastic Compute Cloud (EC2) and the Apache module Phusion Passenger to give you a straightforward, automated, and repeatable deployment process.
    </p>
<p>
      It builds on work started by <a href="http://nutrun.com/weblog/phusion-passenger-on-amazon-ec2/">George Malamidis</a> and developed further whist deploying <a href="http://www.we-workout.com">my side project</a>.
    </p>
<p>
      Using rubybroker-ec2 you will bootstrap a Debian instance (ami-bded09d4) with the following stack; Ruby 1.8.7, Rubygems 1.2.0, Apache2, Passenger, Mysql and Git. Your application will be stored in the ephemeral storage (/mnt) and Apache will be configured correctly to serve it with Phusion Passenger.
    </p>
<h2>
      Prerequisites<br />
    </h2>
<p>
      To use rubybroker-ec2 you will need the following:
    </p>
<ol>
<li>An <span class="caps">EC2</span> account setup and configured to manage <span class="caps">EC2</span> instances (described in detail <a href="http://docs.amazonwebservices.com/AWSEC2/2007-08-29/GettingStartedGuide/">here</a>).
      </li>
<li>A Merb application versioned in a Git repository with all dependancies stored in its “gems” directory.
      </li>
<li>The Capistrano gem installed, <code>capify .</code> run on the application and the basic configuration of your application name and Git scm details completed.
      </li>
</ol>
<p>
      Once you have this you can follow the next few steps to very quickly get you application live.
    </p>
<h2>
      Configuration<br />
    </h2>
<p>
      The first step is to <a href="http://www.neophiliac.net/downloads/rubybroker-ec2-0.0.1.gem">download</a> and install the gem:
    </p>
<p>
      <code>sudo gem install ruby-broker-ec2-0.0.1.gem</code>
    </p>
<p>
      Add it as a requirement at the bottom of your Capfile:
    </p>
<pre name="code" class="ruby">
 load 'deploy' if respond_to?(:namespace) # cap2 differentiator
 Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
 load 'config/deploy'
 require "rubybroker-ec2"
</pre>
<p>
      now copy the following configuration into your deploy.rb file and complete the first section with your <span class="caps">AWS</span> credentials:
    </p>
<pre name="code" class="ruby">
 # Replace the examples with your AWS credentials
 set :account_id, "your account id here"
 set :access_key_id, "your access key id here"
 set :secret_access_key, "you secret access key here"
 set :pk, "your pk here"
 set :cert, "your cert here"
 set :keypair, "your keypair here" 

 # Complete this section in when instance started
 set :instance_id, "your instance id from cap instance:start here"
 set :instance_url, "your instance id from cap instance:describe here" 

 role :app, instance_url
 role :web, instance_url
 role :db,  instance_url, :primary =&gt; true
</pre>
<h2>
      Up and Running<br />
    </h2>
<p>
      The next few steps bootstrap an instance for you, configure Capistrano so it can access it and install the final pieces of software which are not part of the <span class="caps">AMI</span>.
    </p>
<p>
      Get the instance started an instance with:
    </p>
<p>
      <code>cap instance:start</code>
    </p>
<p>
      The output of this command will contain the instance id, this should be entered in the :instance_id field of you deploy.rb. When this is completed invoke:
    </p>
<p>
      <code>cap instance:describe</code>
    </p>
<p>
      In the description of the instance should be the instance url (its looks something like ec2-75-111-111-111.compute-1.amazonaws.com) which is required for your deploy.rb. Note: it may take a few attempts to get the instance url while the instance starts up.
    </p>
<p>
      Thats Capistrano configured which allows us to install and configure the final pieces of software using:
    </p>
<p>
      <code>cap instance:bootstrap</code>
    </p>
<p>
      The instance will now have the full stack on but mysql will require some configuration specific to your application. The easiest was to do this is to connect to the instance using:
    </p>
<p>
      <code>cap instance:ssh</code>
    </p>
<p>
      You can set mysql root password and create the production database:
    </p>
<p>
      <code>mysqladmin -u root password [passowrd]</code> <code>mysqladmin -u root -p create [databasename]</code>
    </p>
<h3>
      Application Specific Configuration<br />
    </h3>
<p>
      This is also the time to configure the instance for any requirements specific to your project.
    </p>
<p>
      For my side project I had to ensure that the instance could access my git repository which is hosted at GitHub. This is as easy as creating a authentication key with:
    </p>
<p>
      <code>ssh-keygen -t rsa</code>
    </p>
<p>
      then coping the contents of ~/.ssh/id_rsa.pb to the “Deploy Keys” of the admin section of the GitHub repository.
    </p>
<p>
      I also required RMagick and ImageMagick which I installed using the following command:
    </p>
<p>
      <code>apt-get install imagemagick librmagick-ruby1.8 libfreetype6-dev xml-core</code>
    </p>
<p>
      When you have finished your own customisation you are ready to deploy.
    </p>
<h2>
      Deployment<br />
    </h2>
<p>
      Phusion Passenger supports Merb applications through the Rack interface. So before your first deployment you need ensure you have a file named config.ru to the root your application containing the following:
    </p>
<pre name="code" class="ruby">
 # config.ru
 require 'rubygems'
 require 'merb-core' 

 Merb::Config.setup(:merb_root   =&gt; ".",
                   :environment =&gt; ENV['RACK_ENV'])
 Merb.environment = Merb::Config[:environment]
 Merb.root = Merb::Config[:merb_root]
 Merb::BootLoader.run 

 run Merb::Rack::Application.new
</pre>
<p>
      The actual deployment steps are the same as the standard Capistrano deployment but the implementation has been customised for this stack.
    </p>
<p>
      Set up the directories on the server:
    </p>
<p>
      <code>cap deploy:setup</code>
    </p>
<p>
      Deploy the code, migrate the database and start Apache with:
    </p>
<p>
      <code>cap deploy:cold</code>
    </p>
<p>
      And… Thats it! Hitting your instance url you should now see you app.
    </p>
<h2>
      Other Commands<br />
    </h2>
<p>
      rubybroker-ec2 also includes helpers for a few other common commands.
    </p>
<p>
      Tell Passenger to restart your application with:
    </p>
<p>
      <code>cap deploy:restart</code>
    </p>
<p>
      Analyze Phusion Passenger’s and Apache’s real memory usage with:
    </p>
<p>
      <code>cap passenger:memory_stats</code>
    </p>
<p>
      Inspect Phusion Passenger’s internal status with:
    </p>
<p>
      <code>cap passenger:status</code>
    </p>
<h2>
      Problems?<br />
    </h2>
<p>
      If you don’t see your application you will need to dig around the in Apache error logs and most of the time you can get a pretty good idea of what went wrong. These can be found <code>/var/log/apache2/error.log</code> and <code>/mnt/apps/{application}/current/logs/error.log</code>.
    </p>
<p>
      The first time I deployed the couple of problems I had were:
    </p>
<ul>
<li>Wrong permissions on the cache directories
      </li>
<li>Sass not generating <span class="caps">CSS</span> when running under Apache
      </li>
</ul>
<h2>
      <span class="caps">TODO</span>’s<br />
    </h2>
<p>
      There are a few feature still which include:
    </p>
<ul>
<li>Add the domain name to the configuration
      </li>
<li>Configure caching to work correctly with Apache / passenger
      </li>
<li>Configure <span class="caps">MYSQL</span> to work from the ephemeral storage
      </li>
</ul>
<h2>
      References and Links<br />
    </h2>
<ul>
<li>
        <a href="http://nutrun.com/weblog/phusion-passenger-on-amazon-ec2/">Phusion Passenger on Amazon <span class="caps">EC2</span></a>
      </li>
<li>
        <a href="http://docs.amazonwebservices.com/AWSEC2/2007-08-29/GettingStartedGuide/"><span class="caps">EC2</span> Gettings started Guide</a>
      </li>
<li>
        <a href="http://www.modrails.com/documentation/Users%20guide%202.0.html">Phusion Passenger Users Guide</a>
      </li>
<li>
        <a href="http://wiki.merbivore.com/pages/phusion-passenger">Merb Wiki</a>
      </li>
<li>
        <a href="http://www.modrails.com/videos/passenger.mov">Passenger Screencast</a>
      </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.neophiliac.net/2008/08/31/rubybroker-ec2-easy-deployment-to-phusion-passenger-on-amazon-ec2/feed/</wfw:commentRss>
<enclosure url="http://www.modrails.com/videos/passenger.mov" length="18988364" type="video/quicktime" />
		</item>
		<item>
		<title>Merb 0.9.5 select helper</title>
		<link>http://www.neophiliac.net/2008/08/29/merb-095-select-helper/</link>
		<comments>http://www.neophiliac.net/2008/08/29/merb-095-select-helper/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 12:12:14 +0000</pubDate>
		<dc:creator>michael.daniel.jones</dc:creator>
		
		<category><![CDATA[merb]]></category>

		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.neophiliac.net/?p=70</guid>
		<description><![CDATA[I spent the last day helping to upgrade an application to Merb 0.9.5. There were a few problems with the select helper and we created this quick and dirty monkey patch to fix. Patch and tests to come.

module Merb::Helpers::Form::Builder
  class Base
    def update_bound_select(method, attrs)
      attrs[:value_method] &#124;&#124;= [...]]]></description>
			<content:encoded><![CDATA[<p>I spent the last day helping to upgrade an application to Merb 0.9.5. There were a few problems with the select helper and we created this quick and dirty monkey patch to fix. Patch and tests to come.</p>
<pre name="code" class="ruby">
module Merb::Helpers::Form::Builder
  class Base
    def update_bound_select(method, attrs)
      attrs[:value_method] ||= :to_s
      attrs[:text_method] ||= :to_s
      attrs[:selected] ||= @obj.send(attrs[:value_method])
    end

    def options(col, text_meth, value_meth, sel, b = nil)
      ([b] + col.map do |item|
        if item.is_a?(Hash) || item.is_a?(Array)
          text = item.last
          value = item.first
        elsif item.is_a?(String)
          text = text_meth ? item.send(text_meth) : item
          value = text_meth ? item.send(value_meth) : item
        else
          text = item.send(text_meth)
          value = item.send(value_meth)
        end

        option_attrs = {:value => value}
        option_attrs.merge!(:selected => "selected") if value == sel
        tag(:option, text, option_attrs)
      end).join
    end
  end
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.neophiliac.net/2008/08/29/merb-095-select-helper/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Finding those irritating puts</title>
		<link>http://www.neophiliac.net/2008/07/28/finding-those-irritating-puts/</link>
		<comments>http://www.neophiliac.net/2008/07/28/finding-those-irritating-puts/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 21:41:08 +0000</pubDate>
		<dc:creator>michael.daniel.jones</dc:creator>
		
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.neophiliac.net/?p=58</guid>
		<description><![CDATA[Recently a couple of bits of debug have cropped up in the tests on my project and it&#8217;s been irritating me a little more each time I run my tests. Today it became too much and it was time to track them down. I knew they were is a spec somewhere, so in the spec_helper [...]]]></description>
			<content:encoded><![CDATA[<p>Recently a couple of bits of debug have cropped up in the tests on my project and it&#8217;s been irritating me a little more each time I run my tests. Today it became too much and it was time to track them down. I knew they were is a spec somewhere, so in the spec_helper I added the following to print out the description of the test instead of the actual debug.</p>
<pre name="code" class="ruby">def new_puts(test)
  $stdout.puts(self.description)
end

alias :p :new_puts
alias :puts :new_puts</pre>
<p>Debug free test output. Conditions are perfect.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neophiliac.net/2008/07/28/finding-those-irritating-puts/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Blogging again&#8230;</title>
		<link>http://www.neophiliac.net/2008/07/28/blogging-again/</link>
		<comments>http://www.neophiliac.net/2008/07/28/blogging-again/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 21:18:41 +0000</pubDate>
		<dc:creator>michael.daniel.jones</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.neophiliac.net/?p=57</guid>
		<description><![CDATA[Its been over a year, so I cleared out all the old posts, installed the latest version of workpress and started work on a new theme. All I need now is to find something to say&#8230; *sigh*
]]></description>
			<content:encoded><![CDATA[<p>Its been over a year, so I cleared out all the old posts, installed the latest version of workpress and started work on a new theme. All I need now is to find something to say&#8230; *sigh*</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neophiliac.net/2008/07/28/blogging-again/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
