class Synco::ServerScope
Public Class Methods
new(server, script_scope, from = nil)
click to toggle source
Calls superclass method
# File lib/synco/scope.rb, line 173 def initialize(server, script_scope, from = nil) super(server) @script_scope = script_scope @from = from end
Public Instance Methods
group()
click to toggle source
# File lib/synco/scope.rb, line 184 def group @group ||= @script_scope.group end
logger()
click to toggle source
# File lib/synco/scope.rb, line 180 def logger @logger ||= @script_scope.logger end
run(*command, from: @from, **options)
click to toggle source
# File lib/synco/scope.rb, line 188 def run(*command, from: @from, **options) # We are invoking a command from the given server, so we need to use the shell to connect.. if from and !from.same_host?(self) if chdir = options.delete(:chdir) command = ["synco", "--root", chdir, "spawn"] + command end command = self.connection_command + ["--"] + command end logger.info("shell") {[command, options]} options[:out] ||= LogPipe.new(logger) options[:err] ||= LogPipe.new(logger, :error) status = self.group.spawn(*command, **options) logger.debug{"Process finished: #{status}."} options[:out].close options[:err].close unless status.success? raise CommandFailure.new(command, status) end end