Class: Kamal::Configuration::Role::Healthcheck
- Inherits:
-
Object
- Object
- Kamal::Configuration::Role::Healthcheck
- Defined in:
- lib/kamal/configuration/role/healthcheck.rb
Constant Summary collapse
- DEFAULT_PATH =
"/up"- DEFAULT_INTERVAL =
1- DOCKER_ONLY_KEYS =
Everything that only ever reaches docker as a
--health-*flag. An exec probe emits none of those, so combining them would silently drop whatever the operator wrote. %w[ cmd port path interval timeout retries start_period start_interval ]
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#healthcheck_config ⇒ Object
readonly
Returns the value of attribute healthcheck_config.
Instance Method Summary collapse
- #args ⇒ Object
-
#cmd ⇒ Object
The command docker runs inside the container.
-
#exec ⇒ Object
The probe kamal
docker execs from the deploy host during a boot, for images whose HEALTHCHECK cannot be changed. - #exec? ⇒ Boolean
-
#initialize(healthcheck_config:, context: "healthcheck") ⇒ Healthcheck
constructor
A new instance of Healthcheck.
- #interval ⇒ Object
- #path ⇒ Object
- #port ⇒ Object
Constructor Details
#initialize(healthcheck_config:, context: "healthcheck") ⇒ Healthcheck
Returns a new instance of Healthcheck.
12 13 14 15 16 |
# File 'lib/kamal/configuration/role/healthcheck.rb', line 12 def initialize(healthcheck_config:, context: "healthcheck") @healthcheck_config = healthcheck_config @context = context validate! end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
9 10 11 |
# File 'lib/kamal/configuration/role/healthcheck.rb', line 9 def context @context end |
#healthcheck_config ⇒ Object (readonly)
Returns the value of attribute healthcheck_config.
9 10 11 |
# File 'lib/kamal/configuration/role/healthcheck.rb', line 9 def healthcheck_config @healthcheck_config end |
Instance Method Details
#args ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/kamal/configuration/role/healthcheck.rb', line 47 def args return [] if exec? optionize({ "health-cmd" => cmd, "health-interval" => duration(interval), "health-timeout" => duration(healthcheck_config["timeout"]), "health-retries" => healthcheck_config["retries"], "health-start-period" => duration(healthcheck_config["start_period"]), "health-start-interval" => duration(healthcheck_config["start_interval"]) }.compact) end |
#cmd ⇒ Object
The command docker runs inside the container. Custom commands win; otherwise we build the same curl check Kamal 1 shipped.
20 21 22 |
# File 'lib/kamal/configuration/role/healthcheck.rb', line 20 def cmd healthcheck_config["cmd"] || http_health_check end |
#exec ⇒ Object
The probe kamal docker execs from the deploy host during a boot, for images whose
HEALTHCHECK cannot be changed. Deploy-time only: docker never runs it, so docker ps
shows no (healthy) and docker inspect keeps no probe history.
27 28 29 |
# File 'lib/kamal/configuration/role/healthcheck.rb', line 27 def exec healthcheck_config["exec"] end |
#exec? ⇒ Boolean
31 32 33 |
# File 'lib/kamal/configuration/role/healthcheck.rb', line 31 def exec? exec.present? end |
#interval ⇒ Object
43 44 45 |
# File 'lib/kamal/configuration/role/healthcheck.rb', line 43 def interval healthcheck_config.fetch("interval", DEFAULT_INTERVAL) end |
#path ⇒ Object
39 40 41 |
# File 'lib/kamal/configuration/role/healthcheck.rb', line 39 def path healthcheck_config.fetch("path", DEFAULT_PATH) end |
#port ⇒ Object
35 36 37 |
# File 'lib/kamal/configuration/role/healthcheck.rb', line 35 def port healthcheck_config["port"] end |