Wednesday, May 30, 2007

Mongrel, Capistrano and Rollbacks

In the deployment chapter of the Agile Web Development with Rails book, (27.5 Setting up a Deployment Environment), they use mongrel_rails cluster::configure to generate a mongrel_cluster.yml config file. There is a problem though, with this generated config file, as is points to a PID file using a relative path log/mongrel.pid. The problem shows up when doing a rollback...

When rolling back with Capistrano, the "current" directory gets relinked to the "latest - 1" release, and the latest release is deleted. This means mongrel's running directory is deleted. As a direct result, mongrel cannot find log/mongrel.pid anymore. So when capistrano restarts the mongrel servers, they fail to delete their PID files. Because log/ is a shared folder between all the releases, upon restart of the "latest - 1" release, mongrel finds stale PID files in there and refuses to start.

The solution is simply to use fully specified paths for the pid_file in config/mongrel_cluster.yml

No comments: