Class: OsCtld::Cli::Daemon

Inherits:
Object
  • Object
show all
Defined in:
lib/osctld/cli/daemon.rb

Class Method Summary collapse

Class Method Details

.run(opts) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/osctld/cli/daemon.rb', line 5

def self.run(opts)
  Process.setproctitle('osctld: main')
  OsCtl::Lib::Logger.setup(opts.log, facility: opts.log_facility)
  d = OsCtld::Daemon.create(opts.config)
  stopping = false

  %w[INT TERM].each do |sig|
    Signal.trap(sig) do
      next if stopping

      stopping = true

      Thread.new do
        d.stop
      end.join
    end
  end

  d.setup
end