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!
December 15th, 2008 at 5:52 am
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.
December 16th, 2008 at 9:52 pm
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
December 17th, 2008 at 1:06 pm
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.
November 23rd, 2009 at 1:33 am
[...] 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 [...]