Module: Izzup

Defined in:
lib/izzup.rb,
lib/izzup/izzup.rb,
lib/izzup/version.rb,
lib/izzup/izzup_error.rb

Defined Under Namespace

Classes: IzzupError

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.assert(*args) ⇒ Object

see if they are up true/false



12
13
14
15
16
# File 'lib/izzup/izzup.rb', line 12

def self.assert(*args)
    found = true
    args.each {|p| found = found && izzup(p)}
    found
end

.demand(*args) ⇒ Object

require these or fail with izzup error



5
6
7
8
9
# File 'lib/izzup/izzup.rb', line 5

def self.demand(*args)
    args.each do |p|
        raise IzzupError, "#{self.name} dying because #{p} is not up" unless izzup(p) 
    end
end

.izzup(process, count = 1) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/izzup/izzup.rb', line 18

def self.izzup(process, count=1)
    up = 0
    begin
        up = %x{ps ax | grep #{process} | grep -v grep | wc -l}.strip().to_i
    rescue
        raise StandardError, "#{self.name} will probably only work on a *NIX machine"
    end
    up == count
end