Class: MailRoom::HealthCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/mail_room/health_check.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ HealthCheck

Returns a new instance of HealthCheck.



7
8
9
10
11
12
# File 'lib/mail_room/health_check.rb', line 7

def initialize(attributes = {})
  @address = attributes[:address]
  @port = attributes[:port]

  validate!
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



5
6
7
# File 'lib/mail_room/health_check.rb', line 5

def address
  @address
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/mail_room/health_check.rb', line 5

def port
  @port
end

#runningObject (readonly)

Returns the value of attribute running.



5
6
7
# File 'lib/mail_room/health_check.rb', line 5

def running
  @running
end

Instance Method Details

#quitObject



25
26
27
28
29
# File 'lib/mail_room/health_check.rb', line 25

def quit
  @running = false
  @server&.shutdown
  @thread&.join(60)
end

#runObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/mail_room/health_check.rb', line 14

def run
  @server = create_server

  @thread = Thread.new do
    @server.start
  end

  @thread.abort_on_exception = true
  @running = true
end