Sha256: 15d811dd29fa6fcf10d9517c373a77c4fa69f22117641aae76b30a5f08da02e4

Contents?: true

Size: 794 Bytes

Versions: 5

Compression:

Stored size: 794 Bytes

Contents

#!/usr/bin/ruby
require 'rubygems'
$:.unshift(File.join(File.dirname(__FILE__), "lib"))
require 'poolparty'

def notify(mess)
  `/usr/local/bin/growlnotify --image #{File.expand_path(File.dirname(__FILE__))}/../assets/clouds.png -m "Your #{PoolParty.options.keypair} cloud #{mess}"`
end

@master = PoolParty::Master.new

@@size = @master.nodes.size

notify("has #{@@size} nodes")

blk = lambda {
  loop do
    sz = @master.nodes.size
    PoolParty.message "Your cloud has #{sz} nodes from #{@@size} nodes"
    unless @@size == sz
      if @@size > sz 
        notify("shrank to #{sz} nodes")
      else
        notify("grew to #{sz} nodes") 
      end
      @@size = sz
    end
    
    @master.reset!
    wait 20.seconds
  end
}

PoolParty::Application.production? ? daemonize(&blk) : blk.call

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
auser-poolparty-0.0.9 bin/poolnotify
auser-poolparty-0.1.0 bin/poolnotify
auser-poolparty-0.1.1 bin/poolnotify
auser-poolparty-0.1.2 bin/poolnotify
jtzemp-poolparty-0.1.2 bin/poolnotify