Output logs when healthcheck fails
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user