Configurable Log Lines Number in Healthcheck Log Output
This commit is contained in:
@@ -26,7 +26,7 @@ class Kamal::Commands::Healthcheck < Kamal::Commands::Base
|
||||
end
|
||||
|
||||
def logs
|
||||
pipe container_id, xargs(docker(:logs, "--tail", lines, "2>&1"))
|
||||
pipe container_id, xargs(docker(:logs, "--tail", log_lines, "2>&1"))
|
||||
end
|
||||
|
||||
def stop
|
||||
@@ -58,7 +58,7 @@ class Kamal::Commands::Healthcheck < Kamal::Commands::Base
|
||||
config.healthcheck["exposed_port"]
|
||||
end
|
||||
|
||||
def lines
|
||||
config.healthcheck["lines"]
|
||||
def log_lines
|
||||
config.healthcheck["log_lines"]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -149,7 +149,7 @@ class Kamal::Configuration
|
||||
|
||||
|
||||
def healthcheck
|
||||
{ "path" => "/up", "port" => 3000, "max_attempts" => 7, "exposed_port" => 3999, "cord" => "/tmp/kamal-cord", "lines" => 50 }.merge(raw_config.healthcheck || {})
|
||||
{ "path" => "/up", "port" => 3000, "max_attempts" => 7, "exposed_port" => 3999, "cord" => "/tmp/kamal-cord", "log_lines" => 50 }.merge(raw_config.healthcheck || {})
|
||||
end
|
||||
|
||||
def readiness_delay
|
||||
|
||||
@@ -93,7 +93,7 @@ class CommandsHealthcheckTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "logs with custom lines number" do
|
||||
@config[:healthcheck] = { "lines" => 150 }
|
||||
@config[:healthcheck] = { "log_lines" => 150 }
|
||||
assert_equal \
|
||||
"docker container ls --all --filter name=^healthcheck-app-123$ --quiet | xargs docker logs --tail 150 2>&1",
|
||||
new_command.logs.join(" ")
|
||||
|
||||
@@ -224,7 +224,7 @@ class ConfigurationTest < ActiveSupport::TestCase
|
||||
:volume_args=>["--volume", "/local/path:/container/path"],
|
||||
:builder=>{},
|
||||
:logging=>["--log-opt", "max-size=\"10m\""],
|
||||
:healthcheck=>{ "path"=>"/up", "port"=>3000, "max_attempts" => 7, "exposed_port" => 3999, "cord" => "/tmp/kamal-cord", "lines" => 50 }}
|
||||
:healthcheck=>{ "path"=>"/up", "port"=>3000, "max_attempts" => 7, "exposed_port" => 3999, "cord" => "/tmp/kamal-cord", "log_lines" => 50 }}
|
||||
|
||||
assert_equal expected_config, @config.to_h
|
||||
end
|
||||
|
||||
@@ -54,7 +54,7 @@ class MainTest < IntegrationTest
|
||||
assert_equal({ user: "root", auth_methods: [ "publickey" ], keepalive: true, keepalive_interval: 30, log_level: :fatal }, config[:ssh_options])
|
||||
assert_equal({ "multiarch" => false, "args" => { "COMMIT_SHA" => version } }, config[:builder])
|
||||
assert_equal [ "--log-opt", "max-size=\"10m\"" ], config[:logging]
|
||||
assert_equal({ "path" => "/up", "port" => 3000, "max_attempts" => 7, "exposed_port" => 3999, "cord"=>"/tmp/kamal-cord", "lines" => 50, "cmd"=>"wget -qO- http://localhost > /dev/null || exit 1" }, config[:healthcheck])
|
||||
assert_equal({ "path" => "/up", "port" => 3000, "max_attempts" => 7, "exposed_port" => 3999, "cord"=>"/tmp/kamal-cord", "log_lines" => 50, "cmd"=>"wget -qO- http://localhost > /dev/null || exit 1" }, config[:healthcheck])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user