Class: LitmusPaper::SinglePortAgentServer
- Inherits:
-
Object
- Object
- LitmusPaper::SinglePortAgentServer
- Includes:
- AgentCheckServer
- Defined in:
- lib/litmus_paper/single_port_agent_server.rb
Constant Summary collapse
- VALID_NAME_REGEX =
/\A[A-Za-z0-9_:.-]+\z/.freeze
Constants included from AgentCheckServer
Instance Attribute Summary
Attributes included from AgentCheckServer
#control_sockets, #pid_file, #workers
Instance Method Summary collapse
-
#initialize(litmus_paper_config, daemonize, pid_file, port, workers) ⇒ SinglePortAgentServer
constructor
A new instance of SinglePortAgentServer.
- #service_for_socket(socket) ⇒ Object
Methods included from AgentCheckServer
#daemonize?, #respond, #run, #spawn_child, #write_pid
Constructor Details
#initialize(litmus_paper_config, daemonize, pid_file, port, workers) ⇒ SinglePortAgentServer
Returns a new instance of SinglePortAgentServer.
9 10 11 12 |
# File 'lib/litmus_paper/single_port_agent_server.rb', line 9 def initialize(litmus_paper_config, daemonize, pid_file, port, workers) super(litmus_paper_config, daemonize, pid_file, workers) @control_sockets = [TCPServer.new(port)] end |
Instance Method Details
#service_for_socket(socket) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/litmus_paper/single_port_agent_server.rb', line 14 def service_for_socket(socket) _, remote_port, _, remote_ip = socket.peeraddr(:numeric) msg = socket.gets if msg && (m = msg.chomp.match(VALID_NAME_REGEX)) backend_name = m[0] LitmusPaper.logger.info "Received request from #{remote_ip}:#{remote_port} for '#{backend_name}'" backend_name else LitmusPaper.logger.error "Received request from #{remote_ip}:#{remote_port}, but backend name could not be read." nil end end |