Class: Hive::Monitor
Instance Attribute Summary collapse
-
#pools ⇒ Object
readonly
Returns the value of attribute pools.
Instance Method Summary collapse
-
#initialize(configuration) ⇒ Monitor
constructor
A new instance of Monitor.
- #monitor ⇒ Object
- #restart ⇒ Object
-
#stop_all ⇒ Object
monitor.
Methods included from Log
#format_for_logging, #log, #logger, #logger=
Constructor Details
Instance Attribute Details
#pools ⇒ Object (readonly)
Returns the value of attribute pools.
7 8 9 |
# File 'lib/hive/monitor.rb', line 7 def pools @pools end |
Instance Method Details
#monitor ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/hive/monitor.rb', line 16 def monitor status = {} job = ->() do changed = false pools.each do |pool| log pool.name previous = status[pool.name] current = pool.synchronize log: true if previous != current then status[pool.name] = current changed = true end end changed end job = Hive::Idler.new( job, min_sleep: 1, max_sleep: 10 ) ok = true trap("TERM") { ok = false } while ok do job.call end end |
#restart ⇒ Object
51 52 53 54 55 |
# File 'lib/hive/monitor.rb', line 51 def restart pools.each do |pool| pool.restart end end |
#stop_all ⇒ Object
monitor
45 46 47 48 49 |
# File 'lib/hive/monitor.rb', line 45 def stop_all pools.each do |pool| pool.stop_all end end |