The flickraw Rubygem is the most wonderful Ruby Flickr API client library IN THE WORLD. It is also dumb, in one important way. And, in another important way, so am I. Yesterday the combination was rather embarassing...
A Rails app I run uses Flickraw to pull in Flickr photos, but only in a script run by a cron job. However, I listed the gem as a requirement in environment.rb, like a good little boy:
config.gem "flickraw"
Except, Rails takes that to mean you want the gem required at startup. When Flickraw is required it hits the Flickr API to retrieve a list of all the API methods, which it turns into Ruby methods you can call. This makes Flickraw permanently up-to-date and a complete API client, which is what makes it so brilliant. Unfortunately, it turns out that if Flickr is down, Flickraw handles it rather badly: it blows up.
Yesterday, Flickr went down. Passenger spawned a new Rails instance, because that's what it does. On startup, that instance tried to hit api.flickr.com, and couldn't, and brought down the whole app. Ouch. The fix? Just this:
config.gem "flickraw", :lib => false # Stops your app hitting api.flickr.com on startup
I have learnt my lesson.