Passenger + Rack on Dreamhost

December 9th, 2008
by Mark Carey

So I spent a little time a while back trying to figure out the nuances of what was allowed on Dreamhost when using mod_rails for a Rack based application. First since Sinatra wasn’t a DH supplied gem I setup my own rubygems install store following this walk through: http://wiki.dreamhost.com/index.php/RubyGems

Then I installed the Sinatra gem. Finally I created a sinatra application and pointed a DH subdomain @ the public folder of the app. Unfortunately DH doesn’t support putting Rack or Rails apps in sub-directories.

Now, even though I was declaring the GEM_HOME & GEM_PATH variables in the config.ru file Passenger wasn’t picking up them up and so wasn’t finding my sinatra gem. To get around this I used the SetEnv apache declaration declaration in a .htaccess file in the public folder of the app ala:

SetEnv GEM_HOME /home/username/.gems
SetEnv GEM_PATH /home/username/.gems:/usr/lib/ruby/gems/1.8

Also since Dreamhost spins down the application handler pretty quickly and my little test site doesn’t recieve much traffic, the initial startup is slow, but subsequent refreshes make this quick. To get over this initial launchtime I setup a cron job to tickle the app every 5 minutes:

*/5 * * * * /usr/bin/curl http://my.domain.com/ -s -o /dev/null

Now the app loads up quick every time!

Tags: , , ,
Posted in coding | Comments (4)

4 Responses to “Passenger + Rack on Dreamhost”

  1. John Nunemaker Says:

    Hey, great tip on the SetEnv, didn’t even think of that. I was running into the issue myself but not with Sinatra as I chose to vendor it.

  2. Stephan Wehner Says:

    I don’t quite know what the difference to your Sinatra gem is but I haven’t had a problem using these gems on a dreamhost Rails app

    $ ls ~/.gems/gems/
    ferret-0.11.6 sqlite3-ruby-1.2.4 rdiscount-1.2.10 tzinfo-0.3.11

    by placing this at the top of config/environment.rb

    ENV['GEM_PATH'] = ‘/home/username/.gems’

    See you

    Stephan

  3. Mark Carey Says:

    That’s how I would have expected it to work, but however Dreamhost had things setup, Passenger didn’t honor it til I put it in the .htaccess file.

  4. Tickling ruby apps every 5 minutes | PixelMai Says:

    [...] had this idea a long while ago, and when I saw that this method being used by other ruby users hosted on DreamHost, I decided to try it out [...]