Class: ActiveMatrix::Daemon::ProbeServer
- Inherits:
-
Object
- Object
- ActiveMatrix::Daemon::ProbeServer
- Defined in:
- lib/active_matrix/daemon/probe_server.rb
Overview
Lightweight HTTP health probe server using Async::HTTP
Endpoints:
-
GET /health - Returns 200 if healthy, 503 if shutting down
-
GET /status - Returns detailed JSON status
-
GET /metrics - Prometheus-compatible metrics
Instance Attribute Summary collapse
-
#daemon ⇒ Object
readonly
Returns the value of attribute daemon.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(host:, port:, daemon:) ⇒ ProbeServer
constructor
A new instance of ProbeServer.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(host:, port:, daemon:) ⇒ ProbeServer
Returns a new instance of ProbeServer.
19 20 21 22 23 24 |
# File 'lib/active_matrix/daemon/probe_server.rb', line 19 def initialize(host:, port:, daemon:) @host = host @port = port @daemon = daemon @thread = nil end |
Instance Attribute Details
#daemon ⇒ Object (readonly)
Returns the value of attribute daemon.
17 18 19 |
# File 'lib/active_matrix/daemon/probe_server.rb', line 17 def daemon @daemon end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
17 18 19 |
# File 'lib/active_matrix/daemon/probe_server.rb', line 17 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
17 18 19 |
# File 'lib/active_matrix/daemon/probe_server.rb', line 17 def port @port end |
Instance Method Details
#start ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/active_matrix/daemon/probe_server.rb', line 26 def start @thread = Thread.new do Sync do endpoint = Async::HTTP::Endpoint.parse("http://#{host}:#{port}") @server = Async::HTTP::Server.for(endpoint) do |request| handle_request(request) end logger.info "Probe server listening on #{host}:#{port}" @server.run end rescue StandardError => e logger.error "Probe server error: #{e.}" end end |
#stop ⇒ Object
43 44 45 46 |
# File 'lib/active_matrix/daemon/probe_server.rb', line 43 def stop @thread&.kill @thread&.join(1) end |