Extract capture_with_info
This commit is contained in:
@@ -36,7 +36,7 @@ class Mrsk::Cli::App < Mrsk::Cli::Base
|
||||
|
||||
desc "details", "Display details about app containers"
|
||||
def details
|
||||
on(MRSK.config.hosts) { |host| puts_by_host host, capture(*MRSK.app.info, verbosity: Logger::INFO) }
|
||||
on(MRSK.config.hosts) { |host| puts_by_host host, capture_with_info(*MRSK.app.info) }
|
||||
end
|
||||
|
||||
desc "exec [CMD]", "Execute a custom task on servers passed in as CMD='bin/rake some:task'"
|
||||
@@ -46,9 +46,9 @@ class Mrsk::Cli::App < Mrsk::Cli::Base
|
||||
runner = options[:run] ? :run_exec : :exec
|
||||
|
||||
if options[:once]
|
||||
on(MRSK.config.primary_host) { puts capture(*MRSK.app.send(runner, cmd), verbosity: Logger::INFO) }
|
||||
on(MRSK.config.primary_host) { puts capture_with_info(*MRSK.app.send(runner, cmd)) }
|
||||
else
|
||||
on(MRSK.config.hosts) { |host| puts_by_host host, capture(*MRSK.app.send(runner, cmd), verbosity: Logger::INFO) }
|
||||
on(MRSK.config.hosts) { |host| puts_by_host host, capture_with_info(*MRSK.app.send(runner, cmd)) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -78,20 +78,20 @@ class Mrsk::Cli::App < Mrsk::Cli::Base
|
||||
option :once, type: :boolean, default: false, desc: "Only perform runner on primary host"
|
||||
def runner(expression)
|
||||
if options[:once]
|
||||
on(MRSK.config.primary_host) { puts capture(*MRSK.app.exec("bin/rails", "runner", "'#{expression}'"), verbosity: Logger::INFO) }
|
||||
on(MRSK.config.primary_host) { puts capture_with_info(*MRSK.app.exec("bin/rails", "runner", "'#{expression}'")) }
|
||||
else
|
||||
on(MRSK.config.hosts) { |host| puts_by_host host, capture(*MRSK.app.exec("bin/rails", "runner", "'#{expression}'"), verbosity: Logger::INFO) }
|
||||
on(MRSK.config.hosts) { |host| puts_by_host host, capture_with_info(*MRSK.app.exec("bin/rails", "runner", "'#{expression}'")) }
|
||||
end
|
||||
end
|
||||
|
||||
desc "containers", "List all the app containers currently on servers"
|
||||
def containers
|
||||
on(MRSK.config.hosts) { |host| puts_by_host host, capture(*MRSK.app.list_containers, verbosity: Logger::INFO) }
|
||||
on(MRSK.config.hosts) { |host| puts_by_host host, capture_with_info(*MRSK.app.list_containers) }
|
||||
end
|
||||
|
||||
desc "current", "Return the current running container ID"
|
||||
def current
|
||||
on(MRSK.config.hosts) { |host| puts_by_host host, capture(*MRSK.app.current_container_id, verbosity: Logger::INFO) }
|
||||
on(MRSK.config.hosts) { |host| puts_by_host host, capture_with_info(*MRSK.app.current_container_id) }
|
||||
end
|
||||
|
||||
desc "logs", "Show last 100 log lines from app on servers"
|
||||
@@ -107,7 +107,7 @@ class Mrsk::Cli::App < Mrsk::Cli::Base
|
||||
|
||||
on(MRSK.config.hosts) do |host|
|
||||
begin
|
||||
puts_by_host host, capture(*MRSK.app.logs(since: since, lines: lines, grep: grep), verbosity: Logger::INFO)
|
||||
puts_by_host host, capture_with_info(*MRSK.app.logs(since: since, lines: lines, grep: grep))
|
||||
rescue SSHKit::Command::Failed
|
||||
puts_by_host host, "Nothing found"
|
||||
end
|
||||
|
||||
@@ -24,12 +24,12 @@ class Mrsk::Cli::Traefik < Mrsk::Cli::Base
|
||||
|
||||
desc "details", "Display details about Traefik containers from servers"
|
||||
def details
|
||||
on(MRSK.config.traefik_hosts) { |host| puts "Traefik Host: #{host}\n" + capture(*MRSK.traefik.info, verbosity: Logger::INFO) + "\n\n" }
|
||||
on(MRSK.config.traefik_hosts) { |host| puts_by_host host, capture_with_info(*MRSK.traefik.info), type: "Traefik" }
|
||||
end
|
||||
|
||||
desc "logs", "Show last 100 log lines from Traefik on servers"
|
||||
def logs
|
||||
on(MRSK.config.hosts) { |host| puts "Traefik Host: #{host}\n" + capture(*MRSK.traefik.logs) + "\n\n" }
|
||||
on(MRSK.config.hosts) { |host| puts_by_host host, capture(*MRSK.traefik.logs), type: "Traefik" }
|
||||
end
|
||||
|
||||
desc "remove", "Remove Traefik container and image from servers"
|
||||
|
||||
@@ -2,7 +2,11 @@ require "sshkit"
|
||||
require "sshkit/dsl"
|
||||
|
||||
class SSHKit::Backend::Abstract
|
||||
def puts_by_host(host, output)
|
||||
puts "App Host: #{host}\n#{output}\n\n"
|
||||
def capture_with_info(*args)
|
||||
capture(*args, verbosity: Logger::INFO)
|
||||
end
|
||||
|
||||
def puts_by_host(host, output, type: "App")
|
||||
puts "#{type} Host: #{host}\n#{output}\n\n"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user