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}'", health_url ]
end

#removeObject



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

def remove
  pipe \
    container_id_for(container_name: container_name),
    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,
    "-d",
    "--name", container_name_with_version,
    "-p", "#{EXPOSED_PORT}:#{config.healthcheck["port"]}",
    "--label", "service=#{container_name}",
    *web.env_args,
    *config.volume_args,
    config.absolute_image,
    web.cmd
end

#stopObject



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

def stop
  pipe \
    container_id_for(container_name: container_name),
    xargs(docker(:stop))
end