views:

349

answers:

5

I have a small Sinatra app I'm running on a shared hosting account using Passenger. However, the first time the app is accessed after a while, I get a Passenger error page saying the application could not be started. Usually because Sinatra could not be found.

I am assuming this is just a normal delay from when a new instance is spawned. However, is there a way to delay trying to load Siantra until it Passenger has fully loaded?

A: 

I seem to have solved the issue by setting the GEMS_PATH environment variable in the .htaccess file. I haven't encountered the error again. YET!

fatnic
is it a dreamhost account?
Marc Seeger
No. Site5. To be honest this method didn't work either. The only solution I;ve found so far is to setup a cron job to access the site every 5 minutes to keep the passenger instance alive. A bit of a hack but it seems to work.
fatnic
A: 

I am having exactly the same issue on Dreamhost. I guess I need a cron job too, but it seems like a hack. Any other solutions?

Aleksey Dmitriyev
A: 

I took this up with Dreamhost support recently (not a great experience) and eventually they recommended freezing the gems into the application. This is at best a partial solution, because it seems to work for some gems and not for others.

Instead of

require 'sinatra'

I have:

require 'vendor/gems/sinatra-0.9.4/lib/sinatra'

Freezing gems is covered elsewhere, but briefly: to prepare for this, one needs to do

mkdir vendor/gems
cd vendor/gems
gem unpack sinatra

As a result of this change, I never get the startup failure screen quoting sinatra as the file it can't load. However, I still get it for some other gems which require themselves or parts of other gems. Not too clear about the details, but I'm working on the idea of hacking the installed gems to make every "require" use a path directly out of my "vendor" library.

Lemongrass
A: 

I think you may need to add Gem.clear_paths! in there

rogerdpack
A: 

I had a similar problem a long time ago. Updating to a newer Sinatra gem helped me - what version are you running?

Brian Deterling