SwitchTower is a utility that can execute commands in parallel on
multiple servers. It allows you to define tasks, which can include
commands that are executed on the servers. You can also define roles
for your servers, and then specify that certain tasks apply only to
certain roles.
SwitchTower 1.0.1, coming hard on the heels of 1.0.0, fixes the
broken rakefile that was generated for rails applications. Nothing
else was changed.
In addition to SwitchTower 1.0.1, I’d also like to announce
SwitchTower Extensions 1.0.0, a collection of SwitchTower tasks and
methods for use in your own SwitchTower recipes. There are two tasks
provided by this library:
watch_load. Just run “switchtower -r config/deploy -a watch_load”
and you’ll see a display of the current load (1/5/15) for each of
your servers. The display updates every 30 seconds.
watch_requests. Run “switchtower -r config/deploy -a
watch_requests” and you’ll see a display of the current requests/
second of each of your application servers, as harvested from your
application log, in real-time.
Mostly, this library is provided as an example of how to write
SwitchTower extensions, though some may find the tasks themselves
useful. You can install SwitchTower extensions either by downloading
from http://rubyforge.org/projects/switchtower, or by rubygems (gem
install switchtower-ext). Once installed, you simply need to put
“require ‘switchtower/ext/monitor’” in your deploy.rb and the tasks
will be available to you.
In addition to SwitchTower 1.0.1, I’d also like to announce SwitchTower
Extensions 1.0.0, a collection of SwitchTower tasks and methods for use
in your own SwitchTower recipes. There are two tasks provided by this
library:
Ah, very nice. Totally minor, and I know these are just examples, but I
found 3 small issues:
headers doesn’t properly handle a machine name that is exactly 1 char
less than the load width (it doesn’t pad, leaving staggered columns).
hostnames are truncated if they contain dashes – i’m assuming the
regex done is meant to grab the hostname from a fully-qualified name.
on debian (at least) uptime reports "load average: " and not
"averages: "
One feature which I think would be nice to be included with
Switchtower, which I currently implement using my own tasks, is
provision for copying a ready to go database.yml file into the config
folder of the new release.
Because you would typically only check in an example database.yml
file, the way I’ve set things up is to create the database.yml file I
need and store it in the shared folder on the remote server. I’ve then
created a task that copies the database.yml file from shared into the
new release once its been checked out.
I’d submit a patch but to be honest I’m still a rake novice and you
might be able to come up with something more elegant. Here is the code
I’m using if its of any use though:
desc “Copy configured database.yml to new current release”
task :copy_database_settings, :roles => :web do
run “cp #{deploy_to}/shared/database.yml
#{release_path}/config/database.yml”
end
task :after_deploy, :roles => :web do
copy_database_settings
end
The reason why I ask if it could be built in is because its typically
something you need to do with every project and its annoying to have
to copy the above into each new deploy file.
Great work with switchtower though, it truly is excellent.
I’ll definitely consider adding the copy_database_settings task to
the standard tasks, but I wouldn’t make it executed by default
(mostly because that’s not the way we use SwitchTower, and I suspect
there are others that wouldn’t use that feature, either). Another
option, though, is to package that up in a task library (http:// manuals.rubyonrails.org/read/chapter/122), such that it can be easily
added to any of the projects you use.
My apologies for letting this patch languish for so long. It didn’t
make it into 1.0.1 because at that point I was just trying to get the
SwitchTower/Capistrano debacle taken care of and out of the way.
I’ve committed your patch, so it will be part of the next Capistrano
Extensions release. Again, my apologies for not acting on this sooner.