Forum: Ruby on Rails [ANN] SwitchTower 1.0.1, SwitchTower Extensions

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
992fe8c19bbbc27f2b562a9f96efc03d?d=identicon&s=25 Jamis Buck (Guest)
on 2006-02-21 06:18
(Received via mailing list)
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.

    Manual: http://manuals.rubyonrails.org/read/book/17
    Project: http://rubyforge.org/projects/switchtower
    Install: gem install switchtower

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.

- Jamis
E75cda3e915fa209386fae3de962cb6a?d=identicon&s=25 Michael Schoen (Guest)
on 2006-02-22 08:40
(Received via mailing list)
> 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:

1. 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).

2. hostnames are truncated if they contain dashes -- i'm assuming the
regex done is meant to grab the hostname from a fully-qualified name.

3. on debian (at least) uptime reports "load average: " and not
"averages: "

I can give you a patch if you'd like.
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Mikkel Bruun (Guest)
on 2006-02-22 09:30
(Received via mailing list)
Amazing...

Good job Jamis!


Mikkel Bruun

www.strongside.dk    - Football Portal(DK)
nflfeed.helenius.org - Football News(DK)
ting.minline.dk      - Buy Old Stuff!(DK)
992fe8c19bbbc27f2b562a9f96efc03d?d=identicon&s=25 Jamis Buck (Guest)
on 2006-02-22 14:51
(Received via mailing list)
On Feb 22, 2006, at 12:38 AM, Michael Schoen wrote:

> columns).
>
> 2. hostnames are truncated if they contain dashes -- i'm assuming
> the regex done is meant to grab the hostname from a fully-qualified
> name.
>
> 3. on debian (at least) uptime reports "load average: " and not
> "averages: "
>
> I can give you a patch if you'd like.

A patch would be wonderful! Thank-you, Michael.

- Jamis
1e99128ebac5ca41c91940291d315332?d=identicon&s=25 Luke Redpath (Guest)
on 2006-02-22 18:16
(Received via mailing list)
Hi Jamis

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.

On 2/22/06, Jamis Buck <jamis@37signals.com> wrote:
> > 1. headers doesn't properly handle a machine name that is exactly 1
> > I can give you a patch if you'd like.
>
> A patch would be wonderful! Thank-you, Michael.
>
> - Jamis
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
Cheers,
Luke Redpath
www.lukeredpath.co.uk
992fe8c19bbbc27f2b562a9f96efc03d?d=identicon&s=25 Jamis Buck (Guest)
on 2006-02-22 23:00
(Received via mailing list)
Luke,

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.

- Jamis
E75cda3e915fa209386fae3de962cb6a?d=identicon&s=25 Michael Schoen (Guest)
on 2006-02-23 00:40
(Received via mailing list)
> A patch would be wonderful! Thank-you, Michael.

Let me know if the formatting below doesn't work and I'll email you an
attachment. All changes are to monitor.rb:

39,40c39,41
<         padding = size - header.length - 1
<         print " ", "-" * padding if padding > 0
---
 >         padding = size - header.length
 >         print " " if padding > 0
 >         print "-" * (padding - 1) if padding > 1
50c51
<     names = servers.map { |s| s.match(/^(\w+)/)[1] }
---
 >     names = servers.map { |s| s.match(/^([^.]+)/)[1] }
57c58
<     parser = Proc.new { |text| text.match(/averages:
(.*)$/)[1].split(/, /) }
---
 >     parser = Proc.new { |text| text.match(/average.*:
(.*)$/)[1].split(/, /) }
E75cda3e915fa209386fae3de962cb6a?d=identicon&s=25 Michael Schoen (Guest)
on 2006-03-06 22:57
(Received via mailing list)
Jamis -- it doesn't look like this patches made it into the new
Capistrano Extensions...
992fe8c19bbbc27f2b562a9f96efc03d?d=identicon&s=25 Jamis Buck (Guest)
on 2006-03-24 04:14
(Received via mailing list)
Michael,

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.

- Jamis
9618e8fca8d72bf01814276c53c2568c?d=identicon&s=25 Robert MannI (Guest)
on 2006-03-24 12:25
(Received via mailing list)
Luke, this is what I do to "copy" the current database to the current
release:

task :after_deploy do

  # create a link to database.yml
  run <<-CMD
    rm -rf #{current_path}/config/database.yml &&
    ln -nfs #{shared_path}/config/database.yml
#{current_path}/config/database.yml
  CMD

  restart
end
This topic is locked and can not be replied to.