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.
- #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.
150 151 152 153 154 155 |
# File 'lib/synco/scope.rb', line 150 def initialize(server, script_scope, from = nil) super(server) @script_scope = script_scope @from = from end |
Instance Method Details
#group ⇒ Object
157 158 159 |
# File 'lib/synco/scope.rb', line 157 def group @group ||= @script_scope.group end |
#run(*command, from: @from, **options) ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/synco/scope.rb', line 161 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 Console::Event::Spawn.for(*command, **).emit(self) [:out] ||= LogPipe.new [:err] ||= LogPipe.new(level: :error) status = self.group.spawn(*command, **) Console.info(self, "Command completed.", status: status) [:out].close [:err].close unless status.success? raise CommandFailure.new(command, status) end end |