Class: Mrsk::Commands::Healthcheck

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

Constant Summary collapse

EXPOSED_PORT =
3999

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, #run_over_ssh

Constructor Details

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

Instance Method Details

#container_health_logObject



25
26
27
# File 'lib/mrsk/commands/healthcheck.rb', line 25

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

#logsObject



29
30
31
# File 'lib/mrsk/commands/healthcheck.rb', line 29

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

#removeObject



37
38
39
# File 'lib/mrsk/commands/healthcheck.rb', line 37

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

#runObject



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

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", "MRSK_CONTAINER_NAME=\"#{container_name}\"",
    *web.env_args,
    *web.health_check_args,
    *config.volume_args,
    *web.option_args,
    config.absolute_image,
    web.cmd
end

#statusObject



21
22
23
# File 'lib/mrsk/commands/healthcheck.rb', line 21

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

#stopObject



33
34
35
# File 'lib/mrsk/commands/healthcheck.rb', line 33

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