class SidekiqLiviness::Server

Public Class Methods

call(env) click to toggle source
# File lib/sidekiq_liviness/server.rb, line 16
def call(env)
  if Rack::Request.new(env).path != path
    [404, {}, [""]]
  elsif SidekiqLiviness.alive?
    [200, {}, [""]]
  else
    [500, {}, [""]]
  end
end
run!() click to toggle source
# File lib/sidekiq_liviness/server.rb, line 8
def run!
  handler = Rack::Handler.get("webrick")

  Signal.trap("TERM") { handler.shutdown }

  handler.run(self, Port: port, Host: "0.0.0.0")
end

Private Class Methods

path() click to toggle source
# File lib/sidekiq_liviness/server.rb, line 32
def path
  ENV.fetch("SIDEKIQ_LIVINESS_PATH") { "/healthz" }
end
port() click to toggle source
# File lib/sidekiq_liviness/server.rb, line 28
def port
  ENV.fetch("SIDEKIQ_LIVINESS_PORT") { 7433 }
end