module Cuniculus::Plugins::HealthCheck
The HealthCheck
plugin starts a Rack server after consumers are initialized, for health probing. It currently does not perform any additional checks and returns '200 OK' regardless of whether
-
the node can connect to RabbitMQ;
-
consumers are stuck.
The healthcheck stays up as long as the supervisor module is also running.
Enable the plugin with: “`ruby Cuniculus.plugin
(:health_check) “`
Options may be passed as well: “`ruby opts = {
"bind_to" => "127.0.0.1", # Default: "0.0.0.0" "port" => 8080 # Default: 3000 "path" => "alive" # Default: "healtcheck"
} Cuniculus.plugin
(:health_check, opts) “` This starts the server bound to 127.0.0.1 and port 8080, and responds on path “alive”. The server responds with 404 when requests are made to different paths.
Constants
- DEFAULTS
- OPTS_KEY
Public Class Methods
Configure `health_check` plugin
@param plugins_cfg [Hash] Global plugin config hash, passed by Cuniculus
. This should not be modified by plugin users. @param opts [Hash] Plugin specific options. @option opts [String] “bind_to” (“0.0.0.0”) IP address to bind to. @option opts [String] “path” (“healthcheck”) Request path to respond to. Requests to other paths will get a 404 response. @option opts [Numeric] “port” (3000) Port number to bind to. @option opts [Boolean] “quiet” (false) Disable server logging to STDOUT and STDERR. @option opts [String] “server” (“webrick”) Rack server handler to use .
# File lib/cuniculus/plugins/health_check.rb 53 def self.configure(plugins_cfg, opts = {}, &block) 54 opts = opts.transform_keys(&:to_s) 55 invalid_opts = opts.keys - DEFAULTS.keys 56 raise Cuniculus::Error, "Invalid option keys for :health_check plugin: #{invalid_opts}" unless invalid_opts.empty? 57 58 plugins_cfg[OPTS_KEY] = h = opts.slice("bind_to", "path", "port", "quiet", "server") 59 h["block"] = block if block 60 DEFAULTS.each do |k, v| 61 h[k] = v if v && !h.key?(k) 62 end 63 end