Switch to a Commander base to allow lazy loading config

This commit is contained in:
David Heinemeier Hansson
2023-01-12 14:58:17 +01:00
parent d3ab10be22
commit 4aa96d6578
10 changed files with 93 additions and 68 deletions

View File

@@ -3,26 +3,4 @@ require "sshkit/dsl"
include SSHKit::DSL
if (config_file = Rails.root.join("config/deploy.yml")).exist?
MRSK_CONFIG = Mrsk::Configuration.load_file(config_file)
SSHKit::Backend::Netssh.configure { |ssh| ssh.ssh_options = MRSK_CONFIG.ssh_options }
# No need to use /usr/bin/env, just clogs up the logs
SSHKit.config.command_map[:docker] = "docker"
else
# MRSK is missing config/deploy.yml run 'rake mrsk:init'
MRSK_CONFIG = Mrsk::Configuration.new({}, validate: false)
end
# Allow easy full verbosity mode
SSHKit.config.output_verbosity = :debug if ENV["VERBOSE"]
# Set a different verbosity level for the duration of the yield
def verbosity(level)
old_level = SSHKit.config.output_verbosity
SSHKit.config.output_verbosity = level
yield
ensure
SSHKit.config.output_verbosity = old_level
end
MRSK = Mrsk::Commander.new config_file: Rails.root.join("config/deploy.yml"), verbose: ENV["VERBOSE"]