Class: Henry::LoggerService

Inherits:
Object
  • Object
show all
Defined in:
lib/henry/logger_service.rb

Constant Summary collapse

DRB_URI =

Uri where the service will be listening.

'druby://localhost'
DRB_PORTS =

Range of ports to be used.

(8787..8800)

Class Method Summary collapse

Class Method Details

.start(logger) ⇒ Object

Starts the logger service sharing the given Logger.

Parameters:

  • logger (Logger)

    the Logger isntance to be shared.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/henry/logger_service.rb', line 14

def self.start(logger)
  10.times do
    begin
      drb_uri = "#{DRB_URI}:#{rand(DRB_PORTS)}"
      DRb.start_service(drb_uri, logger)
      ENV['DRB_LOGGER_URI'] = drb_uri 
    rescue Errno::EADDRINUSE
    end
  end
  
  return false
end

.stopObject

Stops the logger service.



28
29
30
31
32
# File 'lib/henry/logger_service.rb', line 28

def self.stop
  DRb.stop_service
rescue
  return false
end