I was trying to move my application (Sam) up to Dreamhost over the weekend. It might sound silly, since Welcome has its own server facilities, leased line etc but I ran out of servers and I was reluctant to ask for more out-of-budget hardware. Anyway this application needs to be available for access from France and Singapore and prior experience of hosting applications in Singapore resulted in terrible performance.
So anyway the plans looked great and I took out one that gave me 300GB of bandwidth and 20GB for US $120 a month, which even gave me a free domain to boot. Great deal! The admin panel looked a bit strange (I’m more used to cpanel style) but it was ok. I was planning to use Capistrano to do the deployment, with Subversion as source code control. Dreamhost offers FastCGI, which was great.
The first indication of problem came when I was using Subversion. I struggled half a day to get it up and running ,but I put it down to my inexperience with SVN. Shrugging it off, I tried Capistrano, poring through the wiki and Googling like mad trying to understand and use Capistrano. Learning it was no big and it was easy to use. Using it on Dreamhost was a nightmare. After much creation and deletion of subdomains, I finally gave up on it.
Quite discouraged now, I abandoned Capistrano and manually checked it out from SVN into the directory. To my horror it now gave me a ‘not enough space on device’ error! I had 20GB (it said so in the control panel) but after 19MB I don’t have enough space?? Another flurry of file deletions. I removed my SVN directory to keep the files down to size and tried to upload the files directly from FTP. I uploaded the files successfully. (Later after reporting this error Dreamhost came back with an apology that it was their fault, they were clearing up some files or something).
You can guess how ‘eager’ I was to tackle the MySQL database migration. Fortunately a simple backup and create script did the job. Next thing –making the app work.
Following instructions from the wiki, I created a brand new Rails app from my shell login. Then I changed the settings at this new app to fit the required settings to run it on FastCGI in Dreamhost. Then I moved my code to the domain directory. Does it work? Yes!
Then, no. Randomly, somehow the application would go down in flames with the dreaded ‘Rails application failed to start properly’ error. More checking in the wiki and forums and all over the Web. Apparently Dreamhost randomly kills the dispatch.fcgi process like sitting ducks in a shooting gallery. What the — ?? Some code in the wiki gave a workaround to fix this (a hack, really — before in its last dying gasp, the process will spawn another process to take its place). It works, somewhat. However, some times my app will log me out halfway doing something. Still frustrating, still don’t know how to fix that.
Now, most of the application works. Except a couple of pages. Why? I checked the production log. No errors. Errors on the screen? Nothing. Pissed off now, I tried to run Webrick. Hey hey it works! I go to port 3000 and my app pops up! I go to the recalcitrant page. It works! What the –??
Thoroughly turned off now, I took my controller and view apart, line by line, commenting it and uncommenting it until I get something working and worked my way up from there. A few hours later, I found the problem.
I have this bad habit of putting debugging lines in my code, by printing out strings to the console. Fastest and laziest way of debugging. In other words, I used ‘puts’ or the shorter form — ‘p’. Apparently FastCGI doesn’t support Rails with ‘puts’ and it doesn’t give any error messages, it just says ‘Rails application fails to start properly’. I removed that and it worked!
Then another page failed to load at all. But by this time, my weekend was shot to pieces, and my patience was at its end. Time to sleep it off and fight another day.