Class: Siding::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/siding/worker.rb

Constant Summary collapse

PRESERVED_KEYS =
%w[
  SIDING_SERVER
].freeze
RESOLUTION_KEY =
Invocation::RESOLUTION_KEY
REVISION_KEY =
Invocation::REVISION_KEY
BOOT_SECONDS_KEY =
Invocation::BOOT_SECONDS_KEY
HARNESS_FRAME_PATTERN =

A backtrace line belongs to the tool itself, not the application, if it is either a frame inside this file's own directory or the -e: frame Server::BOOTSTRAP runs as (server.rb spawns the server with ruby -e, so that frame has no path of its own to match). Shared between the uncaught-exception path and the rspec path so the two cannot drift apart.

/\A(?:#{Regexp.escape(__dir__)}\/|-e:)/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection:, message:, project_key:, manifest:, verdict:, boot_seconds: nil) ⇒ Worker

Returns a new instance of Worker.



27
28
29
30
31
32
33
34
35
# File 'lib/siding/worker.rb', line 27

def initialize(connection:, message:, project_key:, manifest:, verdict:, boot_seconds: nil)
  @connection = connection
  @message = message
  @project_key = project_key
  @manifest = manifest
  @verdict = verdict
  @revision_label = verdict.revision_label
  @boot_seconds = boot_seconds
end

Instance Attribute Details

#boot_secondsObject (readonly)

Returns the value of attribute boot_seconds.



25
26
27
# File 'lib/siding/worker.rb', line 25

def boot_seconds
  @boot_seconds
end

#connectionObject (readonly)

Returns the value of attribute connection.



25
26
27
# File 'lib/siding/worker.rb', line 25

def connection
  @connection
end

#manifestObject (readonly)

Returns the value of attribute manifest.



25
26
27
# File 'lib/siding/worker.rb', line 25

def manifest
  @manifest
end

#messageObject (readonly)

Returns the value of attribute message.



25
26
27
# File 'lib/siding/worker.rb', line 25

def message
  @message
end

#project_keyObject (readonly)

Returns the value of attribute project_key.



25
26
27
# File 'lib/siding/worker.rb', line 25

def project_key
  @project_key
end

#revision_labelObject (readonly)

Returns the value of attribute revision_label.



25
26
27
# File 'lib/siding/worker.rb', line 25

def revision_label
  @revision_label
end

#verdictObject (readonly)

Returns the value of attribute verdict.



25
26
27
# File 'lib/siding/worker.rb', line 25

def verdict
  @verdict
end

Instance Method Details

#runObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/siding/worker.rb', line 37

def run
  detach_from_server
  streams = Protocol.receive_streams(connection)
  install_streams(streams)
  apply_environment
  apply_working_directory
  LifeCycle.repair_after_fork
  refresh_application
  announce_state
  watch_the_client
  execute
rescue Protocol::TruncatedMessage
  exit! 1
rescue SystemExit => e
  exit e.status
rescue SignalException => e
  report_uncaught(e)
  die_of(e)
rescue Exception => e
  report_uncaught(e)
  exit! 1
end