Add command to start a bash session
This commit is contained in:
@@ -63,6 +63,17 @@ class Mrsk::Cli::App < Mrsk::Cli::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "bash", "Start a bash session on primary host"
|
||||||
|
option :host, desc: "Start bash on a different host"
|
||||||
|
def bash
|
||||||
|
host = options[:host] || MRSK.config.primary_host
|
||||||
|
|
||||||
|
run_locally do
|
||||||
|
puts "Launching bash session on #{host}..."
|
||||||
|
exec MRSK.app.bash(host: host)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
desc "runner [EXPRESSION]", "Execute Rails runner with given expression"
|
desc "runner [EXPRESSION]", "Execute Rails runner with given expression"
|
||||||
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)
|
||||||
|
|||||||
@@ -47,8 +47,9 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
|||||||
*command
|
*command
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_exec(*command)
|
def run_exec(*command, interactive: false)
|
||||||
docker :run,
|
docker :run,
|
||||||
|
("-it" if interactive),
|
||||||
"--rm",
|
"--rm",
|
||||||
*rails_master_key_arg,
|
*rails_master_key_arg,
|
||||||
*config.env_args,
|
*config.env_args,
|
||||||
@@ -57,7 +58,11 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def console(host: config.primary_host)
|
def console(host: config.primary_host)
|
||||||
"ssh -t #{config.ssh_user}@#{host} '#{exec("bin/rails", "c", interactive: true).join(" ")}'"
|
exec_over_ssh "bin/rails", "c", host: host
|
||||||
|
end
|
||||||
|
|
||||||
|
def bash(host: config.primary_host)
|
||||||
|
exec_over_ssh "bash", host: host
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_containers
|
def list_containers
|
||||||
@@ -73,6 +78,10 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
def exec_over_ssh(*command, host:)
|
||||||
|
"ssh -t #{config.ssh_user}@#{host} '#{run_exec(*command, interactive: true).join(" ")}'"
|
||||||
|
end
|
||||||
|
|
||||||
def service_filter
|
def service_filter
|
||||||
[ "--filter", "label=service=#{config.service}" ]
|
[ "--filter", "label=service=#{config.service}" ]
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user