Class: SupervisorInfo
Constant Summary
HotPotato::Core::CONFIG_PATH
Class Method Summary
collapse
Instance Method Summary
collapse
#acquire_lock, #config, #log, #queue_inject, #queue_subscribe, #release_lock, #set_logger, #stat
Constructor Details
Returns a new instance of SupervisorInfo.
7
8
9
10
11
12
13
|
# File 'lib/hot_potato/supervisor_info.rb', line 7
def initialize(options = {})
@data = {}
@data[:started_at] = options[:started_at] || Time.now
@data[:updated_at] = options[:updated_at] || @data[:started_at]
@data[:hostname] = options[:hostname] || Socket.gethostname
@data[:pid] = options[:pid] || Process.pid
end
|
Class Method Details
.json_create(o) ⇒ Object
55
56
57
58
59
60
61
62
|
# File 'lib/hot_potato/supervisor_info.rb', line 55
def self.json_create(o)
options = {}
options[:started_at] = o["started_at"]
options[:updated_at] = o["updated_at"]
options[:pid] = o["pid"]
options[:hostname] = o["hostname"]
new options
end
|
Instance Method Details
#app_tasks ⇒ Object
23
24
25
|
# File 'lib/hot_potato/supervisor_info.rb', line 23
def app_tasks
stat.keys("hotpotato.apptask.#{@data[:hostname]}.*").count
end
|
#hostname ⇒ Object
27
28
29
|
# File 'lib/hot_potato/supervisor_info.rb', line 27
def hostname
@data[:hostname]
end
|
#key ⇒ Object
15
16
17
|
# File 'lib/hot_potato/supervisor_info.rb', line 15
def key
"hotpotato.supervisor.#{@data[:hostname]}.#{@data[:pid]}"
end
|
#pid ⇒ Object
31
32
33
|
# File 'lib/hot_potato/supervisor_info.rb', line 31
def pid
@data[:pid]
end
|
#started_at ⇒ Object
35
36
37
38
|
# File 'lib/hot_potato/supervisor_info.rb', line 35
def started_at
return nil unless @data[:started_at]
DateTime.parse(@data[:started_at])
end
|
#to_json(*a) ⇒ Object
49
50
51
52
53
|
# File 'lib/hot_potato/supervisor_info.rb', line 49
def to_json(*a)
result = @data
result["json_class"] = self.class.name
result.to_json(*a)
end
|
#to_s ⇒ Object
19
20
21
|
# File 'lib/hot_potato/supervisor_info.rb', line 19
def to_s
@data.to_s
end
|
#touch ⇒ Object
45
46
47
|
# File 'lib/hot_potato/supervisor_info.rb', line 45
def touch
@data[:updated_at] = Time.now
end
|
#updated_at ⇒ Object
40
41
42
43
|
# File 'lib/hot_potato/supervisor_info.rb', line 40
def updated_at
return nil unless @data[:updated_at]
DateTime.parse(@data[:updated_at])
end
|