Class: Apprentice::Sentinel
- Inherits:
-
Object
- Object
- Apprentice::Sentinel
- Includes:
- Configuration, Server
- Defined in:
- lib/apprentice.rb
Overview
This defines the sentinel, i.e. tiny server, Apprentice uses to communicate with e.g. HAProxy’s httpchk method.
Instance Method Summary collapse
-
#initialize ⇒ Sentinel
constructor
This depends on the Configuration module since it uses the Configuration#get_config method.
-
#run ⇒ Object
Starts the EventMachine server.
Methods included from Configuration
Constructor Details
#initialize ⇒ Sentinel
This depends on the Configuration module since it uses the Configuration#get_config method.
Return value
-
@options- set the global variable@optionswhich is used inside #run the start the EventMachine server
19 20 21 |
# File 'lib/apprentice.rb', line 19 def initialize @options = get_config end |
Instance Method Details
#run ⇒ Object
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
34 35 36 37 38 39 40 41 42 43 44 45 |
# 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 |