diff --git a/lib/mrsk/cli/healthcheck.rb b/lib/mrsk/cli/healthcheck.rb index fcaf6bc8..831fdd27 100644 --- a/lib/mrsk/cli/healthcheck.rb +++ b/lib/mrsk/cli/healthcheck.rb @@ -21,6 +21,7 @@ class Mrsk::Cli::Healthcheck < Mrsk::Cli::Base raise end ensure + error capture_with_info(*MRSK.healthcheck.logs) execute *MRSK.healthcheck.stop, raise_on_non_zero_exit: false execute *MRSK.healthcheck.remove, raise_on_non_zero_exit: false end diff --git a/lib/mrsk/commands/healthcheck.rb b/lib/mrsk/commands/healthcheck.rb index 8fd3b23c..34ff3a46 100644 --- a/lib/mrsk/commands/healthcheck.rb +++ b/lib/mrsk/commands/healthcheck.rb @@ -19,16 +19,16 @@ class Mrsk::Commands::Healthcheck < Mrsk::Commands::Base [ :curl, "--silent", "--output", "/dev/null", "--write-out", "'%{http_code}'", health_url ] end + def logs + pipe container_id, xargs(docker(:logs, "2>&1")) + end + def stop - pipe \ - container_id_for(container_name: container_name), - xargs(docker(:stop)) + pipe container_id, xargs(docker(:stop)) end def remove - pipe \ - container_id_for(container_name: container_name), - xargs(docker(:container, :rm)) + pipe container_id, xargs(docker(:container, :rm)) end private @@ -40,6 +40,10 @@ class Mrsk::Commands::Healthcheck < Mrsk::Commands::Base "healthcheck-#{config.service_with_version}" end + def container_id + container_id_for(container_name: container_name) + end + def health_url "http://localhost:#{EXPOSED_PORT}#{config.healthcheck["path"]}" end