Class: Kuroko2::Command::Monitor
- Inherits:
-
Object
- Object
- Kuroko2::Command::Monitor
- Defined in:
- lib/autoload/kuroko2/command/monitor.rb
Constant Summary collapse
- NUM_FAILURES =
15
Instance Method Summary collapse
- #counter_size ⇒ Object
- #execute ⇒ Object
-
#initialize(hostname:, worker_id:) ⇒ Monitor
constructor
A new instance of Monitor.
Constructor Details
#initialize(hostname:, worker_id:) ⇒ Monitor
Returns a new instance of Monitor.
7 8 9 10 11 12 |
# File 'lib/autoload/kuroko2/command/monitor.rb', line 7 def initialize(hostname:, worker_id:) @hostname = hostname @worker_id = worker_id @counter = Hash.new(0) @intervals = {} end |
Instance Method Details
#counter_size ⇒ Object
34 35 36 |
# File 'lib/autoload/kuroko2/command/monitor.rb', line 34 def counter_size @counter.size end |
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/autoload/kuroko2/command/monitor.rb', line 14 def execute execution_ids = Worker.on(@hostname).pluck(:execution_id).compact executions = Execution.where(id: execution_ids, mailed_at: nil).started executions.each do |execution| if execution.pid if check_process_absence(execution) && log_memory_consumption?(execution) get_memory_consumption(execution).try do |value| execution.log_memory_consumption(value) end end else check_assignment_delay(execution) end end (@counter.keys - executions.map(&:id)).each do |removable_id| @counter.delete(removable_id) end end |