Class: Minus5::Daemon::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/minus5_daemon/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, logger) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
11
# File 'lib/minus5_daemon/base.rb', line 6

def initialize(options, logger)
  @options = options
  @logger = logger
  @active = true
  @sleep_interval = 1
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



13
14
15
# File 'lib/minus5_daemon/base.rb', line 13

def logger
  @logger
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/minus5_daemon/base.rb', line 15

def run
  on_start
  Signal.trap("TERM") do
    logger.debug "TERM signal received"
    @active = false
    on_stop
  end
  while @active
    run_loop
    sleep_with_check
  end
end