Configure Traefik logs and catch all

This commit is contained in:
David Heinemeier Hansson
2023-01-21 12:39:47 +01:00
parent ff636c3df6
commit 652e17f260
2 changed files with 13 additions and 4 deletions

View File

@@ -27,9 +27,14 @@ class Mrsk::Cli::Traefik < Mrsk::Cli::Base
on(MRSK.traefik_hosts) { |host| puts_by_host host, capture_with_info(*MRSK.traefik.info), type: "Traefik" } on(MRSK.traefik_hosts) { |host| puts_by_host host, capture_with_info(*MRSK.traefik.info), type: "Traefik" }
end end
desc "logs", "Show last 100 log lines from Traefik on servers" desc "logs", "Show log lines from Traefik on servers"
option :since, aliases: "-s", desc: "Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)"
option :lines, type: :numeric, aliases: "-n", desc: "Number of log lines to pull from each server"
def logs def logs
on(MRSK.traefik_hosts) { |host| puts_by_host host, capture(*MRSK.traefik.logs), type: "Traefik" } since = options[:since]
lines = options[:lines]
on(MRSK.traefik_hosts) { |host| puts_by_host host, capture(*MRSK.traefik.logs(since: since, lines: lines)), type: "Traefik" }
end end
desc "remove", "Remove Traefik container and image from servers" desc "remove", "Remove Traefik container and image from servers"

View File

@@ -23,8 +23,12 @@ class Mrsk::Commands::Traefik < Mrsk::Commands::Base
docker :ps, "--filter", "name=traefik" docker :ps, "--filter", "name=traefik"
end end
def logs def logs(since: nil, lines: nil)
docker :logs, "traefik", "-n", "100", "-t" docker :logs, "traefik",
(" --since #{since}" if since),
(" -n #{lines}" if lines),
"-t",
"2>&1"
end end
def remove_container def remove_container