Class: Indocker::Launchers::DTO::RemoteOperationDTO

Inherits:
Object
  • Object
show all
Defined in:
lib/indocker/launchers/dto/remote_operation_dto.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(thread, server, operation, message = nil) ⇒ RemoteOperationDTO

Returns a new instance of RemoteOperationDTO.



21
22
23
24
25
26
# File 'lib/indocker/launchers/dto/remote_operation_dto.rb', line 21

def initialize(thread, server, operation, message = nil)
  @thread = thread
  @server = server
  @operation = operation
  @message = message
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



2
3
4
# File 'lib/indocker/launchers/dto/remote_operation_dto.rb', line 2

def message
  @message
end

#operationObject (readonly)

Returns the value of attribute operation.



2
3
4
# File 'lib/indocker/launchers/dto/remote_operation_dto.rb', line 2

def operation
  @operation
end

#serverObject (readonly)

Returns the value of attribute server.



2
3
4
# File 'lib/indocker/launchers/dto/remote_operation_dto.rb', line 2

def server
  @server
end

#threadObject (readonly)

Returns the value of attribute thread.



2
3
4
# File 'lib/indocker/launchers/dto/remote_operation_dto.rb', line 2

def thread
  @thread
end

Class Method Details

.spawn(server, operation, message = nil, &block) ⇒ Object

Runs a remote operation in a thread that keeps its failure to itself, so that wait_remote_operations can re-raise it on join and report which server failed. Left to the global abort_on_exception/report_on_exception defaults, a failed ssh dumps a raw backtrace and tears the deploy down from inside the thread, naming no server at all. The flags are set inside the thread so that they are in place before the operation gets a chance to fail.



10
11
12
13
14
15
16
17
18
19
# File 'lib/indocker/launchers/dto/remote_operation_dto.rb', line 10

def self.spawn(server, operation, message = nil, &block)
  thread = Thread.new do
    Thread.current.abort_on_exception  = false
    Thread.current.report_on_exception = false

    block.call
  end

  new(thread, server, operation, message)
end