class Ignition::BundleStatus

Public Class Methods

new(h={}) click to toggle source
# File lib/ignition/models/bundle_status.rb, line 2
def initialize(h={})
        update(h)
        self.pids = []        if self['pids'].nil?
        self.scale = 0        if self['scale'].nil?

        pp self
end

Public Instance Methods

add_pid(pid) click to toggle source
# File lib/ignition/models/bundle_status.rb, line 10
def add_pid(pid)
        pids << pid
        update_bundle_running_status
end
clean_pids() click to toggle source
# File lib/ignition/models/bundle_status.rb, line 20
def clean_pids
        deleted = 0
        pids.each do |pid|
                if !is_process_running(pid)
                        pids.delete(pid)
                        deleted += 1
                end
        end
        update_bundle_running_status
        deleted
end
is_process_running(pid) click to toggle source
# File lib/ignition/models/bundle_status.rb, line 32
def is_process_running(pid)
        begin
          Process.getpgid( pid )
          true
        rescue Errno::ESRCH
          false
        end
end
remove_pid(pid) click to toggle source
# File lib/ignition/models/bundle_status.rb, line 15
def remove_pid(pid)
        pids.delete(pid)
        update_bundle_running_status
end
update_bundle_running_status() click to toggle source
# File lib/ignition/models/bundle_status.rb, line 41
def update_bundle_running_status
if (self.pids.size == 0)
        self.message = "STOPPED"
else
        self.message = "RUNNING"
        end
end