Module: Eye::Process::Watchers

Included in:
ChildProcess, Eye::Process
Defined in:
lib/eye/process/watchers.rb

Instance Method Summary collapse

Instance Method Details

#add_watchers(force = false) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/eye/process/watchers.rb', line 3

def add_watchers(force = false)
  return unless self.up?

  remove_watchers if force

  if @watchers.blank?
    # default watcher :check_alive
    add_watcher(:check_alive, self[:check_alive_period]) do
      check_alive
    end

    if self[:check_identity]
      add_watcher(:check_identity, self[:check_identity_period]) do
        check_identity
      end
    end

    # monitor children pids
    if self[:monitor_children]
      add_watcher(:check_children, self[:children_update_period]) do
        add_or_update_children
      end
    end

    # monitor conditional watchers
    start_checkers
  else
    warn 'add_watchers failed, watchers are already present'
  end
end

#remove_watchersObject



34
35
36
37
# File 'lib/eye/process/watchers.rb', line 34

def remove_watchers
  @watchers.each_value { |h| h[:timer].cancel }
  @watchers = {}
end