Module: HttpHealthCheck
- Defined in:
- lib/http_health_check.rb,
lib/http_health_check/probe.rb,
lib/http_health_check/utils.rb,
lib/http_health_check/probes.rb,
lib/http_health_check/version.rb,
lib/http_health_check/rack_app.rb,
lib/http_health_check/config/dsl.rb,
lib/http_health_check/probe/result.rb,
lib/http_health_check/utils/karafka.rb,
lib/http_health_check/probes/sidekiq.rb,
lib/http_health_check/probes/ruby_kafka.rb,
lib/http_health_check/probes/delayed_job.rb
Defined Under Namespace
Modules: Config, Probe, Probes, Utils
Classes: ConfigurationError, Error, RackApp
Constant Summary
collapse
- VERSION =
'1.1.0'
Class Method Summary
collapse
Class Method Details
.add_builtin_probes(conf) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/http_health_check.rb', line 27
def self.add_builtin_probes(conf)
if defined?(::Sidekiq)
require_relative 'http_health_check/probes/sidekiq' unless defined?(Probes::Sidekiq)
conf.probe '/readiness/sidekiq', Probes::Sidekiq.new
end
if defined?(::Delayed::Job)
require_relative 'http_health_check/probes/delayed_job' unless defined?(Probes::DelayedJob)
conf.probe '/readiness/delayed_job', Probes::DelayedJob.new
end
conf
end
|
19
20
21
|
# File 'lib/http_health_check.rb', line 19
def self.configure(&block)
@rack_app = RackApp.configure(&block)
end
|
.rack_app ⇒ Object
23
24
25
|
# File 'lib/http_health_check.rb', line 23
def self.rack_app
@rack_app ||= RackApp.configure { |c| add_builtin_probes(c) }
end
|
.run_server(port:, host: '0.0.0.0', rack_app: nil) ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/http_health_check.rb', line 45
def self.run_server(port:, host: '0.0.0.0', rack_app: nil)
rack_app ||= ::HttpHealthCheck.rack_app
rack_app_with_logger = ::Rack::CommonLogger.new(rack_app, rack_app.logger)
webrick.run(rack_app_with_logger,
Host: host,
Port: port,
AccessLog: [],
Logger: rack_app.logger)
end
|
.run_server_async(opts) ⇒ Object
41
42
43
|
# File 'lib/http_health_check.rb', line 41
def self.run_server_async(opts)
Thread.new { run_server(**opts) }
end
|
.webrick ⇒ Object
56
57
58
59
60
|
# File 'lib/http_health_check.rb', line 56
def self.webrick
return ::Rack::Handler::WEBrick if Gem::Version.new(::Rack.release) < Gem::Version.new('3')
::Rackup::Handler::WEBrick
end
|