Output logs when healthcheck fails
This commit is contained in:
@@ -21,6 +21,7 @@ class Mrsk::Cli::Healthcheck < Mrsk::Cli::Base
|
|||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
|
error capture_with_info(*MRSK.healthcheck.logs)
|
||||||
execute *MRSK.healthcheck.stop, raise_on_non_zero_exit: false
|
execute *MRSK.healthcheck.stop, raise_on_non_zero_exit: false
|
||||||
execute *MRSK.healthcheck.remove, raise_on_non_zero_exit: false
|
execute *MRSK.healthcheck.remove, raise_on_non_zero_exit: false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,16 +19,16 @@ class Mrsk::Commands::Healthcheck < Mrsk::Commands::Base
|
|||||||
[ :curl, "--silent", "--output", "/dev/null", "--write-out", "'%{http_code}'", health_url ]
|
[ :curl, "--silent", "--output", "/dev/null", "--write-out", "'%{http_code}'", health_url ]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def logs
|
||||||
|
pipe container_id, xargs(docker(:logs, "2>&1"))
|
||||||
|
end
|
||||||
|
|
||||||
def stop
|
def stop
|
||||||
pipe \
|
pipe container_id, xargs(docker(:stop))
|
||||||
container_id_for(container_name: container_name),
|
|
||||||
xargs(docker(:stop))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove
|
def remove
|
||||||
pipe \
|
pipe container_id, xargs(docker(:container, :rm))
|
||||||
container_id_for(container_name: container_name),
|
|
||||||
xargs(docker(:container, :rm))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -40,6 +40,10 @@ class Mrsk::Commands::Healthcheck < Mrsk::Commands::Base
|
|||||||
"healthcheck-#{config.service_with_version}"
|
"healthcheck-#{config.service_with_version}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def container_id
|
||||||
|
container_id_for(container_name: container_name)
|
||||||
|
end
|
||||||
|
|
||||||
def health_url
|
def health_url
|
||||||
"http://localhost:#{EXPOSED_PORT}#{config.healthcheck["path"]}"
|
"http://localhost:#{EXPOSED_PORT}#{config.healthcheck["path"]}"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user