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::MAX_LOG_SIZE

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

#curlObject



18
19
20
# File 'lib/mrsk/commands/healthcheck.rb', line 18

def curl
  [ :curl, "--silent", "--output", "/dev/null", "--write-out", "'%{http_code}'", "--max-time", "2", health_url ]
end

#logsObject



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

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

#removeObject



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

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

#runObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# 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}",
    *web.env_args,
    *config.volume_args,
    config.absolute_image,
    web.cmd
end

#stopObject



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

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