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



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

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

#logsObject



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

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

#removeObject



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

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

#runObject



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

def run
  primary = config.role(config.primary_role)

  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}\"",
    *primary.env_args,
    *primary.health_check_args(cord: false),
    *config.volume_args,
    *primary.option_args,
    config.absolute_image,
    primary.cmd
end

#statusObject



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

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

#stopObject



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

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