Class: EtcdTools::Watchdog::Init

Inherits:
Object
  • Object
show all
Includes:
Config, Etcd, Helpers, Logger, Threads
Defined in:
lib/etcd-tools/watchdog/init.rb

Direct Known Subclasses

VipWatchdog, HAproxy

Instance Method Summary collapse

Methods included from Threads

#thread_etcd, #thread_icmp

Methods included from Etcd

#etcd_connect!, #leader?

Methods included from Helpers

#arp, #arping, #hostname, #iproute

Methods included from Logger

#debug, #err, #info

Constructor Details

#initializeInit



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/etcd-tools/watchdog/init.rb', line 24

def initialize
  @semaphore = {
    log: Mutex.new,
    etcd: Mutex.new
  }
  @config = { debug: false }
  @config = config
  @exit = false
  # handle various signals
  @exit_sigs = ['INT', 'TERM']
  @exit_sigs.each { |sig| Signal.trap(sig) { @exit = true } }
  Signal.trap('USR1') { @config[:debug] = false }
  Signal.trap('USR2') { @config[:debug] = true }
  Signal.trap('HUP') { @config = config }
  if RUBY_VERSION >= '2.1'
    Process.setproctitle('etcd-vip-watchdog')
  else
    $0 = 'etcd-vip-watchdog'
  end
  # Process.setpriority(Process::PRIO_PROCESS, 0, -20)
  # Process.daemon
end