sshkit icon indicating copy to clipboard operation
sshkit copied to clipboard

Allow to use config object per running

Open javierav opened this issue 9 months ago • 0 comments

This PR allows you to configure SSHKit in a multithreaded environment per run. Currently, this isn't possible because much of the configuration is set in a global class variable under SSHKit.config.

While SSHKit is initially intended to run when using Capistrano or Kamal from the command line, where a global configuration is sufficient, if you want to use it to run commands via SSH from a Rails job and you want to configure things like the output log, the default environment, or the command map differently for each run, things get complicated.

Example

require 'sshkit'
require 'sshkit/dsl'
include SSHKit::DSL

config = SSHKit::Configuration.new.tap do |c|
  c.output = MyLogger.new
end

on "example.com", in: :sequence, config: config do |host|
  # ...
end

javierav avatar Mar 31 '25 19:03 javierav