Start remote Rails console on primary host
This commit is contained in:
@@ -47,6 +47,10 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
|||||||
*command
|
*command
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def console
|
||||||
|
"ssh -t #{config.ssh_user}@#{config.primary_host} 'docker exec -it -e RAILS_MASTER_KEY=#{config.master_key} #{config.env_args.join(" ")} #{config.service_with_version} bin/rails c'"
|
||||||
|
end
|
||||||
|
|
||||||
def list_containers
|
def list_containers
|
||||||
docker :container, :ls, "-a", *service_filter
|
docker :container, :ls, "-a", *service_filter
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require "active_support/core_ext/string/inquiry"
|
|||||||
require "erb"
|
require "erb"
|
||||||
|
|
||||||
class Mrsk::Configuration
|
class Mrsk::Configuration
|
||||||
delegate :service, :image, :servers, :env, :registry, :ssh_user, to: :config, allow_nil: true
|
delegate :service, :image, :servers, :env, :registry, to: :config, allow_nil: true
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def load_file(file)
|
def load_file(file)
|
||||||
@@ -78,8 +78,12 @@ class Mrsk::Configuration
|
|||||||
self.class.argumentize "-e", config.env if config.env.present?
|
self.class.argumentize "-e", config.env if config.env.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ssh_user
|
||||||
|
config.ssh_user || "root"
|
||||||
|
end
|
||||||
|
|
||||||
def ssh_options
|
def ssh_options
|
||||||
{ user: config.ssh_user || "root", auth_methods: [ "publickey" ] }
|
{ user: ssh_user, auth_methods: [ "publickey" ] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def master_key
|
def master_key
|
||||||
|
|||||||
@@ -58,6 +58,12 @@ namespace :mrsk do
|
|||||||
on(MRSK_CONFIG.hosts) { |host| puts "App Host: #{host}\n" + capture(*app.exec(ENV["CMD"])) + "\n\n" }
|
on(MRSK_CONFIG.hosts) { |host| puts "App Host: #{host}\n" + capture(*app.exec(ENV["CMD"])) + "\n\n" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "Start Rails Console on primary host"
|
||||||
|
task :console do
|
||||||
|
puts "Launching Rails console on #{MRSK_CONFIG.primary_host}..."
|
||||||
|
exec app.console
|
||||||
|
end
|
||||||
|
|
||||||
namespace :exec do
|
namespace :exec do
|
||||||
desc "Execute Rails command on servers, like CMD='runner \"puts %(Hello World)\""
|
desc "Execute Rails command on servers, like CMD='runner \"puts %(Hello World)\""
|
||||||
task :rails do
|
task :rails do
|
||||||
|
|||||||
Reference in New Issue
Block a user