Start remote Rails console on primary host
This commit is contained in:
@@ -47,6 +47,10 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
*command
|
||||
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
|
||||
docker :container, :ls, "-a", *service_filter
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ require "active_support/core_ext/string/inquiry"
|
||||
require "erb"
|
||||
|
||||
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
|
||||
def load_file(file)
|
||||
@@ -78,8 +78,12 @@ class Mrsk::Configuration
|
||||
self.class.argumentize "-e", config.env if config.env.present?
|
||||
end
|
||||
|
||||
def ssh_user
|
||||
config.ssh_user || "root"
|
||||
end
|
||||
|
||||
def ssh_options
|
||||
{ user: config.ssh_user || "root", auth_methods: [ "publickey" ] }
|
||||
{ user: ssh_user, auth_methods: [ "publickey" ] }
|
||||
end
|
||||
|
||||
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" }
|
||||
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
|
||||
desc "Execute Rails command on servers, like CMD='runner \"puts %(Hello World)\""
|
||||
task :rails do
|
||||
|
||||
Reference in New Issue
Block a user