Extract puts_by_host
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 "App Host: #{host}\n" + capture(*MRSK.app.info, verbosity: Logger::INFO) + "\n\n" }
|
on(MRSK.config.hosts) { |host| puts_by_host host, capture(*MRSK.app.info, verbosity: Logger::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'"
|
||||||
@@ -48,7 +48,7 @@ class Mrsk::Cli::App < Mrsk::Cli::Base
|
|||||||
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(*MRSK.app.send(runner, cmd), verbosity: Logger::INFO) }
|
||||||
else
|
else
|
||||||
on(MRSK.config.hosts) { |host| puts "App Host: #{host}\n" + capture(*MRSK.app.send(runner, cmd), verbosity: Logger::INFO) + "\n\n" }
|
on(MRSK.config.hosts) { |host| puts_by_host host, capture(*MRSK.app.send(runner, cmd), verbosity: Logger::INFO) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -80,18 +80,18 @@ class Mrsk::Cli::App < Mrsk::Cli::Base
|
|||||||
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(*MRSK.app.exec("bin/rails", "runner", "'#{expression}'"), verbosity: Logger::INFO) }
|
||||||
else
|
else
|
||||||
on(MRSK.config.hosts) { |host| puts "App Host: #{host}\n" + capture(*MRSK.app.exec("bin/rails", "runner", "'#{expression}'"), verbosity: Logger::INFO) + "\n\n" }
|
on(MRSK.config.hosts) { |host| puts_by_host host, capture(*MRSK.app.exec("bin/rails", "runner", "'#{expression}'"), verbosity: Logger::INFO) }
|
||||||
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 "App Host: #{host}\n" + capture(*MRSK.app.list_containers, verbosity: Logger::INFO) + "\n\n" }
|
on(MRSK.config.hosts) { |host| puts_by_host host, capture(*MRSK.app.list_containers, verbosity: Logger::INFO) }
|
||||||
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 "App Host: #{host}\n" + capture(*MRSK.app.current_container_id, verbosity: Logger::INFO) + "\n\n" }
|
on(MRSK.config.hosts) { |host| puts_by_host host, capture(*MRSK.app.current_container_id, verbosity: Logger::INFO) }
|
||||||
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,9 +107,9 @@ class Mrsk::Cli::App < Mrsk::Cli::Base
|
|||||||
|
|
||||||
on(MRSK.config.hosts) do |host|
|
on(MRSK.config.hosts) do |host|
|
||||||
begin
|
begin
|
||||||
puts "App Host: #{host}\n" + capture(*MRSK.app.logs(since: since, lines: lines, grep: grep), verbosity: Logger::INFO) + "\n\n"
|
puts_by_host host, capture(*MRSK.app.logs(since: since, lines: lines, grep: grep), verbosity: Logger::INFO)
|
||||||
rescue SSHKit::Command::Failed
|
rescue SSHKit::Command::Failed
|
||||||
puts "App Host: #{host}\nNothing found\n\n"
|
puts_by_host host, "Nothing found"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
require "thor"
|
require "thor"
|
||||||
require "sshkit"
|
require "mrsk/sshkit_with_ext"
|
||||||
require "sshkit/dsl"
|
|
||||||
|
|
||||||
module Mrsk::Cli
|
module Mrsk::Cli
|
||||||
class Base < Thor
|
class Base < Thor
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
require "sshkit"
|
|
||||||
|
|
||||||
module Mrsk::Commands
|
module Mrsk::Commands
|
||||||
class Base
|
class Base
|
||||||
delegate :redact, to: Mrsk::Utils
|
delegate :redact, to: Mrsk::Utils
|
||||||
|
|||||||
8
lib/mrsk/sshkit_with_ext.rb
Normal file
8
lib/mrsk/sshkit_with_ext.rb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
require "sshkit"
|
||||||
|
require "sshkit/dsl"
|
||||||
|
|
||||||
|
class SSHKit::Backend::Abstract
|
||||||
|
def puts_by_host(host, output)
|
||||||
|
puts "App Host: #{host}\n#{output}\n\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user