8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/legion/extensions/health/runners/watchdog.rb', line 8
def expire(expire_time: 60, **_opts)
nodes = []
Legion::Data::Model::Node
.where(status: 'healthy')
.where(
Sequel.lit(
"updated <= DATE_SUB(SYSDATE(), INTERVAL #{expire_time} SECOND)
OR
(updated is null and created <= DATE_SUB(SYSDATE(), INTERVAL #{expire_time} SECOND))"
)
)
.where(active: true)
.each do |node|
Legion::Transport::Messages::NodeHealth.new(status: 'unknown',
node_id: node.values[:id],
hostname: node.values[:name],
timestamp: node.values[:updated]).publish
nodes.push(node.values[:id])
end
log.debug("count: #{nodes.count}")
{ success: true, count: nodes.count, nodes: nodes }
end
|