Class: Sbmt::Outbox::Probes::Probe

Inherits:
Object
  • Object
show all
Defined in:
lib/sbmt/outbox/probes/probe.rb

Constant Summary collapse

DEFAULT_PROBE_PORT =
5555

Class Method Summary collapse

Class Method Details

.run_probesObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sbmt/outbox/probes/probe.rb', line 9

def run_probes
  return unless autostart_probe?

  $stdout.puts "Starting probes..."

  ::HttpHealthCheck.run_server_async(
    port: probe_port,
    rack_app: HttpHealthCheck::RackApp.configure do |c|
      c.logger Rails.logger
      c.probe "/readiness/outbox" do |_env|
        code = Sbmt::Outbox.current_worker.ready? ? 200 : 500
        [code, {}, ["Outbox version: #{Sbmt::Outbox::VERSION}"]]
      end

      c.probe "/liveness/outbox" do |_env|
        code = Sbmt::Outbox.current_worker.alive? ? 200 : 500
        [code, {}, ["Outbox version: #{Sbmt::Outbox::VERSION}"]]
      end
    end
  )
end