Class: EtcdTools::Watchdog::Init

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

Direct Known Subclasses

HAproxy, Vip

Instance Method Summary collapse

Methods included from Threads

#thread_etcd, #thread_icmp

Methods included from Util::Etcd

#etcd_connect!, #leader?

Methods included from Util::Helpers

#arp, #arping, #hostname, #iproute

Methods included from Util::Logger

#debug, #err, #info

Constructor Details

#initializeInit

Returns a new instance of Init.



21
22
23
24
25
26
27
28
29
30
# File 'lib/etcd-tools/watchdog/init.rb', line 21

def initialize
  @config = { debug: false }
  @config = config
  @exit = false
  @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 }
end

Instance Method Details

#setup(proc_name, nice = -20)) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/etcd-tools/watchdog/init.rb', line 32

def setup(proc_name, nice = -20)
  if RUBY_VERSION >= '2.1'
    Process.setproctitle(proc_name)
  else
    $0 = proc_name
  end
  Process.setpriority(Process::PRIO_PROCESS, 0, nice)
  # TODO: Process.daemon ...
end