Class: EtcdTools::Watchdog::Init
- Inherits:
-
Object
- Object
- EtcdTools::Watchdog::Init
- Includes:
- Threads, Util::Config, Util::Etcd, Util::Helpers, Util::Logger
- Defined in:
- lib/etcd-tools/watchdog/init.rb
Instance Method Summary collapse
-
#initialize ⇒ Init
constructor
A new instance of Init.
- #setup(proc_name, nice = -20)) ⇒ Object
Methods included from Threads
Methods included from Util::Etcd
Methods included from Util::Helpers
#arp, #arping, #hostname, #iproute
Methods included from Util::Logger
Constructor Details
#initialize ⇒ Init
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 |