Class: Kamal::Configuration::Healthcheck

Inherits:
Object
  • Object
show all
Includes:
Validation
Defined in:
lib/kamal/configuration/healthcheck.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validation

#validate!, #validation_yml

Constructor Details

#initialize(healthcheck_config:, context: "healthcheck") ⇒ Healthcheck

Returns a new instance of Healthcheck.



6
7
8
9
# File 'lib/kamal/configuration/healthcheck.rb', line 6

def initialize(healthcheck_config:, context: "healthcheck")
  @healthcheck_config = healthcheck_config || {}
  validate! @healthcheck_config, context: context
end

Instance Attribute Details

#healthcheck_configObject (readonly)

Returns the value of attribute healthcheck_config.



4
5
6
# File 'lib/kamal/configuration/healthcheck.rb', line 4

def healthcheck_config
  @healthcheck_config
end

Instance Method Details

#cmdObject



15
16
17
# File 'lib/kamal/configuration/healthcheck.rb', line 15

def cmd
  healthcheck_config.fetch("cmd", http_health_check)
end

#cordObject



35
36
37
# File 'lib/kamal/configuration/healthcheck.rb', line 35

def cord
  healthcheck_config.fetch("cord", "/tmp/kamal-cord")
end

#intervalObject



31
32
33
# File 'lib/kamal/configuration/healthcheck.rb', line 31

def interval
  healthcheck_config.fetch("interval", "1s")
end

#log_linesObject



39
40
41
# File 'lib/kamal/configuration/healthcheck.rb', line 39

def log_lines
  healthcheck_config.fetch("log_lines", 50)
end

#max_attemptsObject



27
28
29
# File 'lib/kamal/configuration/healthcheck.rb', line 27

def max_attempts
  healthcheck_config.fetch("max_attempts", 7)
end

#merge(other) ⇒ Object



11
12
13
# File 'lib/kamal/configuration/healthcheck.rb', line 11

def merge(other)
  self.class.new healthcheck_config: healthcheck_config.deep_merge(other.healthcheck_config)
end

#pathObject



23
24
25
# File 'lib/kamal/configuration/healthcheck.rb', line 23

def path
  healthcheck_config.fetch("path", "/up")
end

#portObject



19
20
21
# File 'lib/kamal/configuration/healthcheck.rb', line 19

def port
  healthcheck_config.fetch("port", 3000)
end

#set_port_or_path?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/kamal/configuration/healthcheck.rb', line 43

def set_port_or_path?
  healthcheck_config["port"].present? || healthcheck_config["path"].present?
end

#to_hObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/kamal/configuration/healthcheck.rb', line 47

def to_h
  {
    "cmd" => cmd,
    "interval" => interval,
    "max_attempts" => max_attempts,
    "port" => port,
    "path" => path,
    "cord" => cord,
    "log_lines" => log_lines
  }
end