Rails Deployment Tinkering
So I developed my first little Rails application recently.
Given how “RAD-y” and agile the development process feels in the Rails framework (at least compared to something like Spring MVC + Hibernate), I was expecting the actual deployment of the thing to be a breeze.
I was wrong.
Rails deployment is done using a tool or framework called Capistrano. Capistrano kinda resembles Rake; you define tasks and variables in a deploy script (like a Rakefile), hooking it directly to your SCM system of choice (Subversion in my case). Running the Capistrano deployment tasks then refreshes your Rails server environment with the latest and greatest version of your application, directly from the repository (Capistrano can be used for automating a bunch of other remote tasks too).
Actually making this process work as expected took me a whole evening, several cups of coffee and occasional copious swearing. I don’t recall every roadblock I encountered, but the following two were the big (ie. most time-consuming) gotchas for me:
- Capistrano is a little sensitive to Subversion repository url structure. Putting the root of your Rails app in applicationName\trunk\applicationName\ works. Putting your app root directly in applicationName\trunk\ does not; you get a “bad url” error thrown back at you by Capistrano (perhaps from the underlying ruby SVN wrapper).
- Printing anything to stdout can eff things up for the underlying webserver. I had some debug puts statements in my application. These were no problem when testing on localhost. In the server environment, however, they caused the pages to be served as plain text instead of html. Took me some googling to figure that one out.