class Apprentice::Sentinel
This defines the sentinel, i.e. tiny server, Apprentice
uses to communicate with e.g. HAProxy’s httpchk method.
Public Class Methods
new()
click to toggle source
This depends on the Configuration
module since it uses the Configuration#get_config
method.
Return value¶ ↑
-
@options
- set the global variable@options
which is used insiderun
the start the EventMachine server
# File lib/apprentice.rb, line 19 def initialize @options = get_config end
Public Instance Methods
run()
click to toggle source
Starts the EventMachine server
Special conditions¶ ↑
We are trapping the signals INT
and TERM
here in order to shut down the EventMachine gracefully.
Attributes¶ ↑
-
@options.ip
- The server binds to this specific ip -
@options.port
- The server uses this specific port to expose its limited HTTP interface to the world -
@options
- Gets passed to the server as a whole to be used with Server::EventServer#initialize
# File lib/apprentice.rb, line 34 def run EM.run do Signal.trap('INT') { EventMachine.stop } Signal.trap('TERM') { EventMachine.stop } EventMachine.start_server( @options.ip, @options.port, Server::EventServer, @options ) end end