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