Rails Shared Hosting Gotcha #3,942
Running Rails in a shared hosting environment is a prickly one. This fact has been well documented for years now. But I like to torture myself sometimes. I read a quote recently that I am reminded of: "if it hurts, do it more often".
Well, I'm running, or attempting to run, three Rails sites on a few different shared hosting servers at Dreamhost. Generally they run OK but sometimes they die and I cannot bring them back to life without a few hours of frantic keyboard strokes. Usually these times coincide with Dreamhost updating one of the following: rails, ruby or rubygems. Updating ruby and rubygems does not happen regularly enough to cause much pain, but I swear to fucking god it seems like they are updating rails every 3 months and every time my apps crash. Yes I have frozen my rails. Yes I am specifying a RAILS_GEM_VERSION in my environment.rb. The problem persists.
The latest failure occurred when rails was updated to 2.1.1. I watched it happen first only on one of the sites, then, when Dreamhost came around to updating the other server that I have apps on, those apps crashed as well. This was the interesting error I received:
RubyGem version error: actionpack(2.0.2 not = 1.13.6)
The code was still running through my frozen rails, but on one of the requirements it was falling out of my frozen rails and trying to require a more recent version of actionpack. You bastard!
/home/user-name/domain.com/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb 495 in `require'
Turns out the fix was easy enough though, but it required manually freezing my rails instead of using the rake task (rake rails:freeze:gems) since the version of rails I was freezing to (1.2.6) was no longer installed on my server.
Step one was to download the version I wanted from github. Then upload it to my app's vendor directory, unpack it, rename it to 'rails' and then touch tmp/restart.txt to tell passenger to reload my app.
Hey, it worked. Really weird because I froze rails back in June of this year to Rails 1.2.6, and everything was fine then.
Dreamhost's support was surprisingly silent on helping me with this. First they let me support request sit in their queue for over 3 days, then they replied with a "hey not our fault, your scripts are borked" reply. Great. Well it's over 5 days later now and I can fix it my own damn self, thank you very much.
Currently looking for VPS plans. Word on the street is slicehost which starts at a mere $20/month for 256 MB of VPS goodness. Hmmm....... there will be more on this topic I am sure.
<
p>Update: I was talking with a coworker about this and he reminded me that the older frozen Rails would not include the actionwebservice directory whereas if you freeze Rails now, it does. Also, the Rails 1.6 that I downloaded from github also included the actionwebservice directory. That seems to be the major difference between the frozen rails that was failing for me vs. the frozen rails that's running fine now.
11:03 PM | 8 CommentsComments
- Grant Hutchins on October 07, 2008, at 11:42 PM
- Rasmus on October 09, 2008, at 04:30 AM
- justin on October 09, 2008, at 07:52 AM
- Eric Murrell on October 09, 2008, at 09:59 PM
- Mike on October 11, 2008, at 02:12 PM
- Ian on October 14, 2008, at 07:33 AM
- Dave S on October 16, 2008, at 05:52 PM
- justin on October 17, 2008, at 07:37 AM