It's no secret that I (heart) SwitchTower. Just yesterday we used it to automate the deployment of another production Rails application. It took just a few minutes to set up and test SwitchTower, and we'll get paid back every time we deploy a new production release. Indeed, SwitchTower is a fantastically good investment, and yet I think it's generally undervalued. So here's a quick rundown (because it was quick) of what happened yesterday in hopes that you'll give SwitchTower a spin.
After some minor tweaks to the default SwitchTower recipe file, I created the deployment directory structure on the production machine by typing the following on my local machine:
rake remote_exec ACTION=setup
From my local machine I updated the code on the production server and restarted the app by typing
Had things gone bad, I would have rolled back to the previously deployed version of the app by typing
At this point we have Apache, the FastCGI processes, and MySQL 5 all running on the same production server. Down the road we may well distribute those three tiers across multiple machines. How would the deployment procedure change? Well, fortunately it wouldn't.
When you execute a SwitchTower task, it's run in parallel (and atomically) on all machines that are assigned to that task in the recipe file. Think about that: As the number of machines and processes in your deployment environment increases, your deployment procedure remains constant at one command.
But it gets event better. SwitchTower is an extremely well thought out piece of machinery. Everywhere you look inside you see the signs of a tool borne out of necessity (and pain). Take, for example, the case where you want to see all the file diffs between what's in the trunk of your version control system and what got deployed in the last production release. Again, it's one command:
Or what about the case where you need to temporarily disable web access while you do a bit of maintenance on the production app? It would be nice to put up a friendly maintenance screen for users to gaze at while you go about your chores. Except arranging those niceties can really cut into your downtime. That is, unless you're using the single-command power of SwitchTower. From your local machine, type
rake remote_exec ACTION=disable_web \ UNTIL="14:00 MST" \ REASON="a database upgrade"
And, voila, your users see a friendly status page.
Not friendly enough? No worries. You can customize the template however you like. And when you've finished that database upgrade, simply take down the maintenance page with (wait for it) a single command:
rake remote_exec ACTION=enable_web
Now that's the kind of automation I'm talking about!
You honestly can't afford not to be using SwitchTower. The manual is short and very well written. The software is friendly and works just as you'd expect. Everything I've shown here is all built in, and you can easily customize and extend it to suit your deployment environment. I know we'll be using SwitchTower a lot more in coming weeks, and I hope you will, too.