Class: Ignition::BundleStatus
- Inherits:
-
Hash
- Object
- Hash
- Ignition::BundleStatus
show all
- Defined in:
- lib/ignition/models/bundle_status.rb
Instance Method Summary
collapse
Methods inherited from Hash
#except, #except!, #method_missing, #remove_empty, zip
Constructor Details
Returns a new instance of BundleStatus.
2
3
4
5
6
7
8
|
# 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
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Hash
Instance Method Details
#add_pid(pid) ⇒ Object
10
11
12
13
|
# File 'lib/ignition/models/bundle_status.rb', line 10
def add_pid(pid)
pids << pid
update_bundle_running_status
end
|
#clean_pids ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# 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) ⇒ Object
32
33
34
35
36
37
38
39
|
# 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) ⇒ Object
15
16
17
18
|
# 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 ⇒ Object
41
42
43
44
45
46
47
|
# 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
|