The maze book for programmers!
mazesforprogrammers.com

Algorithms, circle mazes, hex grids, masking, weaving, braiding, 3D and 4D grids, spheres, and more!

DRM-Free Ebook

The Buckblog

assorted ramblings by Jamis Buck

SwitchTower 0.10.0

2 January 2006 — 2-minute read

It’s a week later than I said, but it’s here at last: SwitchTower 0.10.0. I figure there will be one or two more releasees before 1.0.

This release addresses several longstanding bug reports and adds some nice new functionality. To update, just do:

  gem install --include-dependencies switchtower

And then update each of your apps by doing:

  switchtower --apply-to /path/to/app

When prompted, keep your config/deploy.rb file, and replace your lib/tasks/switchtower.rake file.

You can read the complete changelog, but here’s a quick overview of some of the most notable changes:

Bugs Fixed

  • Handle SSH password prompts formatted like “someone’s password:”
  • Allow the sudo password to be reentered if it was entered incorrectly
  • Errors during checkout are now caught and reported early
  • Avoid timeouts on long-running commands
  • Add a small sleep during command processing to give the CPU a rest
  • Rake tasks should work much more nicely on Windows (you’ll need to do switchtower --apply-to /path/to/app to update, keeping your config/deploy.rb and overwriting lib/tasks/switchtower.rake)

New Features

ssh_options variable

There is now an ssh_options hash that you can use in your recipe files to set custom SSH connection options, like setting a non-standard port to connect on:

1
ssh_options[:port] = 2345

Allow svn checkouts to use export instead of co

If you don’t want to use an svn co to checkout your code, you can set the :checkout variable to :export, and SwitchTower will use svn export instead.

1
set :checkout, :export

This variable defaults to :co.

update_current task

There is now an update_current task that just does an svn up on the last-deployed release. This is useful for trivial updates, like when a template changed.

cleanup task

You can easily remove unused releases from your deployment directories with the cleanup task. It will (by default) keep the 5 most recent releases, and delete the rest.

SFTP for file transfers

Net::SFTP is now used (if it is available) for file transfers. This should make transferring large files more robust, as well as allow binary characters in files.

restart_via variable

You can now set the :restart_via variable to :run, if you need to have the restart task use run instead of sudo.

1
set :restart_via, :run

This defaults variable to :sudo.

Reader Comments

Fantastic! Thanks, Jamis!
This is cool. I have found one issue though - the *cleanup* task directly calls sudo to delete the old directories. I don't have sudo, so it fails for me. Since the directories were created by my switchtower user, they should be able to be removed by that same use, so sudo shouldn't be necessary for this task. Thanks for a great tool.
Interesting. Now, what is it? (I'm not being snarky, I'm honestly curious; your post assumes the reader knows what this thing is. Completely my opinion here, but I've always held that any announcement should at least include a short 1 sentence blurb as to what the thing being upgraded is/does/is for/etc.)
MC, apologies for not describing ST. I've been posting about it quite a bit for the last month or two and figured anyone following my blog would already know the details. Basically, SwitchTower is a tool for automating tasks on multiple remote machines. It was designed specifically for deploying Rails applications, but can be used for much more than that. The manual for it is at http://manuals.rubyonrails.com/read/book/17, and should give much more information if you are interested.
Jamis- Thanks for all your hard work! Switchtower is one of the killer features of rails for me and I am very appreciative.
Jamis - Switchtower 0.10 rocks. I just had to do a rake rollback and boy was I glad to have it.
Yeeehaaa! :>
Love it. I'm pleasantly suprised to see the update_current task. Silly question, after upgrading to 0.10 I thought I'd try running `rake update_current` but get "Don't know how to build task 'update_current'" Yet it shows in the output of available tasks. I did allow the switchtower --apply-to command to replace the .tasks file. I'm obviously missing something, er, obvious. Thanks for SW.
Jack, for most ST tasks, you have to use the remote_exec task to access them:
  rake remote_exec ACTION=update_current
This is because the rake tasks and the switchtower tasks are executed in two different realms, and rake only knows about the rake tasks. (The switchtower.rake file defines a few rake tasks for the commonly used switchtower tasks--you can always define more for those you use frequently.)
I'm trying to run ST 0.10.0 on WinXP. I've run "switchtower --apply-to myapp" and edited deploy.rb. But whenever I run: rake remote_exec ACTION=blah it says: rake aborted! don't know how to build task 'remote_exec' What am I missing?
Dave, what version of Rails do you have installed? Also, is there a file in lib/tasks called switchtower.rake?
I echo Tom's comment about needing sudo for the cleanup task. Why sudo for this if the directory is created by the user in question? I'm having difficulty getting this particular piece to work because of it.
Sean, In the next release, the use of sudo will be configurable. The reason it is there is because we (at 37signals) need it--either David or I may be deploying the app, so we can't be guaranteed to be able to delete the other's directories.
Jamis, I have 0.10.0 installed (says --version), but I don't have the "cleanup" task defined anywhere ?
Eli, note that the cleanup task is not available via "rake cleanup" in 0.10.0. You need to do "rake remote_exec ACTION=cleanup".
I get the "don't know how to build task 'remote_exec'" error also. I do have the switchtower.rake file in lib/tasks, but rails -v returns 'unknown version'. We're one or two releases behind on rails; is 'remote_exec' something that's fixed in later releases? thanks
It's not remote_exec that's broken in earlier releases--earlier releases of rails didn't support the .rake extension files that switchtower uses. How large (in bytes) is your Rakefile? It ought to be quite small, if you're using a supported version of rails.
The rakefile is 1,361 bytes.
Matt, I'm guessing you're using an older version of Rails that doesn't work with the .rake extension files. My rakefile, for instance, is only 307 bytes. You'll need to upgrade your rails to take advantage of the rails/switchtower integration, but note that you can use switchtower with any rails version--you just have to use the switchtower command directly instead of via rake:
  switchtower -vvvv -r config/deploy -a deploy
(Replace "deploy" with your command of choice. Use the "show_tasks" command to see all available SwitchTower tasks.)
Perfect, thanks