<?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>McKinney Station &#187; Sinatra</title>
	<atom:link href="http://www.mckinneystation.com/categories/sinatra/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mckinneystation.com</link>
	<description>Ruby on Rails web application development for Dallas/Fort Worth and all of North Texas.</description>
	<lastBuildDate>Wed, 02 Sep 2009 14:29:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Deploying Sinatra Apps on Dreamhost</title>
		<link>http://www.mckinneystation.com/2008/10/09/deploying-sinatra-apps-on-dreamhost/</link>
		<comments>http://www.mckinneystation.com/2008/10/09/deploying-sinatra-apps-on-dreamhost/#comments</comments>
		<pubDate>Fri, 10 Oct 2008 05:22:47 +0000</pubDate>
		<dc:creator>Geoffrey</dc:creator>
				<category><![CDATA[Dallas]]></category>
		<category><![CDATA[Dreamhost]]></category>
		<category><![CDATA[Sinatra]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[microapps]]></category>

		<guid isPermaLink="false">http://www.mckinneystation.com/?p=86</guid>
		<description><![CDATA[So I LOVE creating small apps as a way of trying out new things.  The problem is that I rarely deploy them anywhere.  Many end up sitting in my /workspace directory until I decide I need to reclaim the space and probably won&#8217;t work on it ever again.
Recently, the Dallas Relevance folks have [...]]]></description>
			<content:encoded><![CDATA[<p>So I LOVE creating <a href="http://www.mckinneystation.com/2008/06/03/microapps-encourage-hacking/">small apps as a way of trying out new things</a>.  The problem is that I rarely deploy them anywhere.  Many end up sitting in my <code>/workspace</code> directory until I decide I need to reclaim the space and probably won&#8217;t work on it ever again.</p>
<p>Recently, the Dallas <a href="http://www.thinkrelevance.com">Relevance</a> folks have been meeting at Panera while we wait for our office space to materialize.  Most of the time everything works out nicely: free wifi, decent coffee, plenty of room to spread out.  But one thing that doesn&#8217;t work correctly while at Panera is <a href="http://tinyurl.com">tinyurl.com</a>.  For some reason, tinyurl is blocked by Panera filters.  This would be fine for most, but since my twitter friends insist on using tinyurl to post links in their tweets, it is annoying not being able to see what is going on.</p>
<h2>Microapp to the Rescue</h2>
<p>So I figured this would be an opportunity for simple little that let me enter the tinyurl, figure out where it was going to redirect to, and go ahead and redirect me there.  This way I am never accessing the evil tinyurl.com directly from the Panera network, but instead letting my little app do that for me.</p>
<p>The app was pretty easy to write.  I used <a href="http://github.com/bmizerany/sinatra">Sinatra</a> and created one &#8220;controller&#8221; and one &#8220;view&#8221;.  Within a few minutes, Sinatra had &#8220;taken the stage on port 4567&#8243; and my app was working.  Locally.</p>
<h2>Give the app a home</h2>
<p>The next challenge came when I tried to deploy it to my trusty <a href="http://www.dreamhost.com">Dreamhost</a> account.  I love Dreamhost for playing around with small apps.  You get <a href="http://dreamhost.com/hosting.html">unlimited domains,</a> they have <a href="http://dreamhost.com/hosting-panel.html">a pretty cool admin control panel</a>, and they support deploying Rails applications with <a href="http://www.modrails.com/">Passenger Phusion</a>.  And since <a href="http://www.modrails.com/documentation/Users%20guide.html#_deploying_a_rack_based_ruby_application">Passenger Phusion 2.0 supports Rack enabled Ruby apps</a>, I knew I should be able to deploy this new app to my Dreamhost account.  A quick search turned up a useful post with <a href="http://www.gittr.com/index.php/archive/deploying-rack-apps-on-dreamhost-via-passenger-including-sinatra/">information on deploying to Sinatra apps on Dreamhost</a>.  Unfortunately, the first attempt didn&#8217;t work.</p>
<h2>Always check the logs</h2>
<p>So I went to the logs to see what went wrong&#8230; wait there weren&#8217;t any logs!  Fortunately I found this post for <a href="http://www.gittr.com/index.php/archive/logging-with-sinatra-and-passenger-another-try/">logging with Sinatra apps</a>.  Unfortunately, the logs didn&#8217;t help.  Apparently, my problem ran deeper.  So like all good debuggers, I started commenting out code and printing out where I was in the app.  The first thing I commented out was the called to render the view using ERB.  Turns out you can configure where the root of the app is located.  Apparently the root path for a Sinatra app running on Dreamhost is not exactly the path where you deployed it.  <code>Sinatra::Application.default_options[:root]</code> looked like this: </p>
<pre><code>/home/.machinename/username/app.domain.com/Rack: /home/.machinename/username</code></pre>
<h2>Additional configuration needed</h2>
<p>Looking through the Sinatra source turned up the needed configuration changes need:</p>
<pre><code>path = "/path/to/app"

Sinatra::Application.default_options.merge!(
  :root =&gt; path,
  :views =&gt; path + '/views',
  :public =&gt; path + '/public',
  :run =&gt; false,
  :env =&gt; :production
)</code></pre>
<p>A quick deploy later and the application was up and running.  Tomorrow we are meeting at Panera and I will get to see what everyone is tweeting about.</p>
<h2>Addendum: Deployment too?</h2>
<p>Since Sinatra apps are so small, you could just copy everything up to the server manually.  But I like have a little Rake task to do that for me.  It just touches the <code>tmp/restart.txt</code> that Passenger uses to know when to restart and then uses rsync to copy the files up to the server.</p>
<pre><code>desc 'Deploy to the server using rsync'
task :restart do
  sh "touch tmp/restart.txt"
end

desc 'Deploy to the server using rsync'
task :deploy =&gt; :restart do
  cmd = "rsync -ruv * #{USERNAME}@#{DOMAIN}:#{DEPLOY_PATH}"
  sh cmd
end</code></pre>
<h2>Take a look at the code</h2>
<p>I have <a href="http://github.com/gdagley/panera">posted the code on Github</a> for everyone to take a look at.  Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mckinneystation.com/2008/10/09/deploying-sinatra-apps-on-dreamhost/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microapps Encourage Hacking</title>
		<link>http://www.mckinneystation.com/2008/06/03/microapps-encourage-hacking/</link>
		<comments>http://www.mckinneystation.com/2008/06/03/microapps-encourage-hacking/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 14:54:46 +0000</pubDate>
		<dc:creator>Geoffrey</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[RailsConf]]></category>
		<category><![CDATA[SQLite]]></category>
		<category><![CDATA[Sinatra]]></category>
		<category><![CDATA[SliceHost]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[microapps]]></category>
		<category><![CDATA[mongrel]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://www.mckinneystation.com/2008/06/03/microapps-encourage-hacking/</guid>
		<description><![CDATA[photo by Jeff Belmonte
I am back from RailsConf 2008 and two of my favorite talks were &#8220;Microapps for Fun and Profit&#8221; by Erik Kastner and &#8220;23 Hacks&#8221; by Nathaniel Talbott.  I have recently been toying around with creating small little apps where I can try out new ideas and sharpen my skills.  
One [...]]]></description>
			<content:encoded><![CDATA[<div class="shadow left"><img src='http://www.mckinneystation.com/wp-content/uploads/2008/06/small_train.jpg' alt='Small Train' /><br/><span class="credit">photo by <a href="http://www.flickr.com/photos/jeffbelmonte/">Jeff Belmonte</a></span></div>
<p>I am back from <a href="http://www.railsconf.com">RailsConf 2008</a> and two of my favorite talks were &#8220;<a href="http://metaatem.net/2008/05/30/my-railsconf-talk">Microapps for Fun and Profit</a>&#8221; by <a href="http://metaatem.net/">Erik Kastner</a> and &#8220;<a href="http://blog.talbott.ws/articles/2008/5/31/23-hacks-railsconf-2008">23 Hacks</a>&#8221; by <a href="http://blog.talbott.ws/">Nathaniel Talbott</a>.  I have recently been toying around with creating small little apps where I can try out new ideas and sharpen my skills.  </p>
<p>One of those apps is the <a href="http://www.templategeneratorpro.com">Template Generator Pro</a>.  It was a really simple little app the generates funny <a href="http://coverletters.templategeneratorpro.com">cover letters</a>, <a href="http://twoweeknotice.templategeneratorpro.com">two week notices</a>, <a href="http://jobs.templategeneratorpro.com">job postings</a>, and more.  Not a lot to it.  What did I learn?  I deployed it to <a href="http://www.slicehost.com">SliceHost</a> (my previous apps have been deployed to <a href="http://dreamhost.com/">DreamHost</a>) and starting learning more about hosting and system administration.  I also had a chance to port the <a href="http://nonsense.sourceforge.net/">Nonsense Perl script</a> to <a href="http://nonsense.rubyforge.org/">a Ruby version</a>.  That was fun!</p>
<h2>Tools of the Trade</h2>
<p>What am I using for my microapps?  The first ones (<a href="http://www.catechizeme.com">CathechizeMe</a> and <a href="http://www.templategeneratorpro.com">TemplateGeneratorPro</a>) were small Rails applications.  But that is alot of overhead and not a lot of &#8220;micro&#8221; in that.  So for new things I am looking at <a href="http://sinatrarb.com/">Sinatra</a> for a framework and <a href="http://stone.rubyforge.org/">Stone</a> or <a href="http://ar.rubyonrails.com/">ActiveRecord</a> with <a href="http://www.sqlite.org/">SQLite</a> for persistance.  I like <a href="http://jquery.com/">JQuery</a> for the Javascript and <a href="http://code.google.com/p/blueprintcss/">BluePrint CSS</a> helps me make it look pretty fairly easily.  <a href="http://www.oswd.org/">Open Source Web Design</a> and <a href="http://www.openwebdesign.org">Open Web Design</a> help to stimulate the creative aspects of the designs.</p>
<h2>Check it Out</h2>
<p>You can see some my little hacks being stored on my GitHub account:  <a href="http://www.github.com/gdagley">http://www.github.com/gdagley</a>. I also have some projects from <a href="http://www.thinkrelevance.com">work</a> at <a href="http://www.github.com/relevance">http://www.github.com/relevance</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mckinneystation.com/2008/06/03/microapps-encourage-hacking/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
