Elasticfox, OSX and iTerm

01 October 2008

applescript ec2 elasticfox osa osx

Elasticfox is a nice extension for managing your relationship with EC2 from within Firefox. It's XUL-based, somewhat homely and odd. But it's so much nicer than dealing with the ec2-* scripts directly and copying Amazon's wacky hash identifiers hither and thither.

But on OSX, the "ssh to this instance" button is wired up to Terminal.app. I can't stand Terminal.app. I much prefer iTerm.

So, a little AppleScript hacking, and Elasticfox now uses iTerm to connect to instances through ssh.

Instead of jamming it all into a dozen -e options on osascript, I just put it in a file, and changed my configuration.

Elasticfox configuration

And the script itself:

  
on run argv
  tell application "iTerm"
    activate
    set cmd to "ssh -i " & item 1 of argv & " " & item 2 of argv
    set myterm to the last terminal
    tell myterm
      launch session "Default Session"
      tell the last session
        write text the cmd
      end tell
    end tell
  end tell
end run

Multiple instances of AS on OSX

29 September 2008

java jboss osx

Rysiek asked me to elucidate my clustering on OSX...

By default, it seems that OSX provides exactly 1 localhost address, unlike RHEL. I normally make use of 127.0.0.1/24 when I'm deploying on Linux, and figured I'd do the same on OSX.

To accomplish this, you need to create some new localhost IPs to play with.

  
sudo ifconfig lo0 alias 127.0.0.10 up
sudo ifconfig lo0 alias 127.0.0.11 up
sudo ifconfig lo0 alias 127.0.0.12 up

Now, when you run your AS with ./run.sh, just pass -b 127.0.0.10 or -b 127.0.0.11 etc, and the entire stack will bind to that IP address.

At this point, I'm allowing each AS instance to share a work directory and such, which is probably not exactly the safest thing to be doing. Normally each cluster node would be a discrete machine with its own JBOSS_HOME.

For the apache config, in /private/etc/apache2/httpd.conf, I uncommented the line to allow vhost file loading:

  
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

Then, in the httpd-vhosts.conf file I fixed it up to include my virtual host for the head-end load-balancing stuff.

The <VirtualHost> is only barely conformant, and even the DocumentRoot is gratuitous, really. It looks like this:

  
<VirtualHost *:80>
  ServerName app.local.ballast
  DocumentRoot "/Users/bob/public_html"

  RewriteEngine on

  RewriteMap    lb      'prg:/Users/bob/bin/load_balancer local.ballast 1 3'
  RewriteRule   ^/(.*)$ ${lb:$1}           [P,L]
</VirtualHost>

What that is doing is passing each requested path to the load_balancer script I've borrowed from I-don't-know-'where. It returns an augmented URL pointing to one of my localhost-bound nodes.

  
#!/usr/bin/env perl
##
##  lb.pl -- load balancing script
##

$| = 1;

$name   = $ARGV[0];         # the hostname base
$first  = $ARGV[1];         # the first server (not 0 here, because 0 is myself)
$last   = $ARGV[2];         # the last server in the round-robin

$cnt = 0;
while (<STDIN>) {
    $server = sprintf("node%d.%s", $cnt+$first, $name);
    $cnt = (($cnt+1) % ($last+1-$first));
    print "http://$server:8080/$_";
}

If a path of /foo/bar is handed to it on STDIN, it'll return something in the format of http://node1.local.ballast:8080/foo/bar or http://node2.local.ballast:8080/foo/bar.

Through the magic of /etc/hosts those friendly names point to the localhost bound AS cluster nodes, along with app.local.ballast pointing to good old traditional 127.0.0.1, where httpd is normally listening. That's my head-end from the httpd-vhosts.conf.

  
127.0.0.1       localhost app.local.ballast

127.0.0.10      node1.local.ballast
127.0.0.11      node2.local.ballast
127.0.0.12      node3.local.ballast

Fire up a browser and I surf to http://app.local.ballast/, apache answers, and immediately and invisibly proxies the request to port 8080 of one of my localhost-bound JBoss AS instances.

Nice.

Boxy To Go

05 December 2006

culture opensource osx tools

Picture 11.pngBeing an OSX user, I've felt massive amounts of unlove from TiVo, in terms of the TiVoDesktop, TiVoToGo, etc. But now, man, the guys behind tivodecode have come to my rescue. While playing with it, I also discovered that the TiVo actually produces a nice XML feed, and mine at least attempts to serve up some RSS (but it ultimately fails).

tivodecode spews out MPEG-2, which QuickTime can't handle natively. You can spend $19.99 at the Apple Store to get the MPEG codec pack, or use DarwinPorts to install MPlayer, which handles MPEG-2 just fine. For free.

Bless all those opensouce geeks out there in the world. Bless each and every one of you.

Knobs

11 July 2006

culture music osx technology

Picture 49.pngI've recently started using iTunes on the G5 hooked to the speakers, instead of the iPod connected to them. Today I realized that I hadn't been listening to anything at all, because iTunes simply never made it to the front of my stack of windows. With the physical iPod situated in front of me, I'm more apt to pick something to listen to.

Digital isn't always better. Sometimes a big-ass knob on a distinct device is functionally better than a whizzy-bang brushed metal UI without a dedicated knob.

Yes, I know the iPod doesn't have a knob. It has an iKnob (aka, the clickwheel with the nipple in the middle). But it's knobesque nonetheless. And the screen is always visible. No repeated command-tab to find it. It's just right there. On the desk.

Menu Bling

20 May 2006

osx technology

How much have you got? (Click to enlarge) Picture 4.png