Class: Synco::ServerScope
- Inherits:
-
Server
- Object
- Controller
- Server
- Synco::ServerScope
- Defined in:
- lib/synco/scope.rb
Instance Attribute Summary
Attributes inherited from Server
#host, #mountpoint, #name, #root, #shell
Attributes inherited from Controller
Instance Method Summary collapse
- #group ⇒ Object
-
#initialize(server, script_scope, from = nil) ⇒ ServerScope
constructor
A new instance of ServerScope.
- #logger ⇒ Object
- #run(*command, from: @from, **options) ⇒ Object
Methods inherited from Server
#connection_command, #connection_string, #full_path, #same_host?, #to_s
Methods inherited from Controller
#abort!, build, #fire, #freeze, #on, #try
Constructor Details
#initialize(server, script_scope, from = nil) ⇒ ServerScope
Returns a new instance of ServerScope.
182 183 184 185 186 187 |
# File 'lib/synco/scope.rb', line 182 def initialize(server, script_scope, from = nil) super(server) @script_scope = script_scope @from = from end |
Instance Method Details
#group ⇒ Object
193 194 195 |
# File 'lib/synco/scope.rb', line 193 def group @group ||= @script_scope.group end |
#logger ⇒ Object
189 190 191 |
# File 'lib/synco/scope.rb', line 189 def logger @logger ||= @script_scope.logger end |
#run(*command, from: @from, **options) ⇒ Object
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/synco/scope.rb', line 197 def run(*command, from: @from, **) # 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 = .delete(:chdir) command = ["synco", "--root", chdir, "spawn"] + command end command = self.connection_command + ["--"] + command end logger.info("shell") {[command, ]} [:out] ||= LogPipe.new(logger) [:err] ||= LogPipe.new(logger, :error) status = self.group.spawn(*command, **) logger.debug{"Process finished: #{status}."} [:out].close [:err].close unless status.success? raise CommandFailure.new(command, status) end end |