Class: Kamal::Commands::Healthcheck

Inherits:
Base
  • Object
show all
Defined in:
lib/kamal/commands/healthcheck.rb

Constant Summary

Constants inherited from Base

Base::DOCKER_HEALTH_LOG_FORMAT, Base::DOCKER_HEALTH_STATUS_FORMAT

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

#container_id_for, #initialize, #make_directory, #make_directory_for, #remove_directory, #run_over_ssh

Constructor Details

This class inherits a constructor from Kamal::Commands::Base

Instance Method Details

#container_health_logObject



24
25
26
# File 'lib/kamal/commands/healthcheck.rb', line 24

def container_health_log
  pipe container_id, xargs(docker(:inspect, "--format", DOCKER_HEALTH_LOG_FORMAT))
end

#logsObject



28
29
30
# File 'lib/kamal/commands/healthcheck.rb', line 28

def logs
  pipe container_id, xargs(docker(:logs, "--tail", log_lines, "2>&1"))
end

#removeObject



36
37
38
# File 'lib/kamal/commands/healthcheck.rb', line 36

def remove
  pipe container_id, xargs(docker(:container, :rm))
end

#runObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/kamal/commands/healthcheck.rb', line 3

def run
  web = config.role(:web)

  docker :run,
    "--detach",
    "--name", container_name_with_version,
    "--publish", "#{exposed_port}:#{config.healthcheck["port"]}",
    "--label", "service=#{config.healthcheck_service}",
    "-e", "KAMAL_CONTAINER_NAME=\"#{config.healthcheck_service}\"",
    *web.env_args,
    *web.health_check_args(cord: false),
    *config.volume_args,
    *web.option_args,
    config.absolute_image,
    web.cmd
end

#statusObject



20
21
22
# File 'lib/kamal/commands/healthcheck.rb', line 20

def status
  pipe container_id, xargs(docker(:inspect, "--format", DOCKER_HEALTH_STATUS_FORMAT))
end

#stopObject



32
33
34
# File 'lib/kamal/commands/healthcheck.rb', line 32

def stop
  pipe container_id, xargs(docker(:stop))
end