Sha256: d1468f0869156dbc1096fdd65f97067877e0c1fcca7396fdf43e9a8da1e29f73
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
class Kamal::Commands::Healthcheck < Kamal::Commands::Base EXPOSED_PORT = 3999 def run web = config.role(:web) docker :run, "--detach", "--name", container_name_with_version, "--publish", "#{EXPOSED_PORT}:#{config.healthcheck["port"]}", "--label", "service=#{container_name}", "-e", "KAMAL_CONTAINER_NAME=\"#{container_name}\"", *web.env_args, *web.health_check_args, *config.volume_args, *web.option_args, config.absolute_image, web.cmd end def status pipe container_id, xargs(docker(:inspect, "--format", DOCKER_HEALTH_STATUS_FORMAT)) end def container_health_log pipe container_id, xargs(docker(:inspect, "--format", DOCKER_HEALTH_LOG_FORMAT)) end def logs pipe container_id, xargs(docker(:logs, "--tail", 50, "2>&1")) end def stop pipe container_id, xargs(docker(:stop)) end def remove pipe container_id, xargs(docker(:container, :rm)) end private def container_name [ "healthcheck", config.service, config.destination ].compact.join("-") end def container_name_with_version "#{container_name}-#{config.version}" end def container_id container_id_for(container_name: container_name_with_version) end def health_url "http://localhost:#{EXPOSED_PORT}#{config.healthcheck["path"]}" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kamal-0.16.1 | lib/kamal/commands/healthcheck.rb |
kamal-0.16.0 | lib/kamal/commands/healthcheck.rb |