I’ve finally found a workable set of deployment practices for getting my little rails apps up and running in shared hosting at TextDrive. None of the actual mechanics are particularly en vogue these days – I’m just using plain old lighttpd with external fcgi processes.

What is kind of fun, though, is that I’ve reduced almost all of the duplication across my deploy.rb files, so now they look like this:

require 'capistrano/ext/textdrive'

set :application, 'reading'
set :domain,      ''

This is exceedingly pleasing to me, because these are the only 2 settings I’d ever change from app to app—precisely what belongs in an application-specific configuration file.

Herewith, a description of the behavior that require line provides:


Run this once for your account.



Run this once for your application. An after_setup task has been defined to call this automatically, but if you write your own, you’ll clobber it—see this test case – so be sure to call textdrive_after_setup if you write a custom after_setup task.



Run this every time you deploy. An after_update_code convenience task has been defined just as above, with the same clobberability caveats.


If you'd like to try it out

This code’s packaged as a gem, but I haven’t released it anywhere yet. So:

svn export
cd capistrano-ext-textdrive
rake install

And then your deploy.rb is going to need a few more lines than mine, since I made the defaults fit my needs and tastes. It will probably end up looking something like this:

require 'capistrano/ext/textdrive'

set :application,   YOUR_APPLICATION
set :domain,        YOUR_DOMAIN
set :user,          YOUR_USERNAME
set :lighttpd_port, YOUR_LIGHTTPD_PORT
set :repository,    YOUR_REPOSITORY_PATH

Do be sure to read through the gem code first to understand what it’s doing – I expect things will generally work fine, but it would be a shame to run into trouble with it.

A few notes

One last unautomated bit is that you’ll need to set ProxyPreserveHost On for each Apache virtual host into which you’re deploying rails apps this way. (See steps 10-12 in this bit of TextDrive documentation.)

Most of this approach comes from Installing a Rails Application at TextDrive, in the TextDrive knowledge base.

See also Shovel, from Geoffrey Grosenbach.