Class: CapistranoMulticonfigParallel::CelluloidWorker

Inherits:
Object
  • Object
show all
Includes:
BaseActorHelper
Defined in:
lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb

Overview

worker that will spawn a child process in order to execute a capistrano job and monitor that process

Defined Under Namespace

Classes: TaskFailed

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseActorHelper

included

Instance Attribute Details

#action_nameObject

Returns the value of attribute action_name.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def action_name
  @action_name
end

#app_nameObject

Returns the value of attribute app_name.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def app_name
  @app_name
end

#clientObject

Returns the value of attribute client.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def client
  @client
end

#current_task_numberObject

Returns the value of attribute current_task_number.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def current_task_number
  @current_task_number
end

#env_nameObject

Returns the value of attribute env_name.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def env_name
  @env_name
end

#env_optionsObject

Returns the value of attribute env_options.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def env_options
  @env_options
end

#exit_statusObject

Returns the value of attribute exit_status.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def exit_status
  @exit_status
end

#filenameObject

Returns the value of attribute filename.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def filename
  @filename
end

#invocation_chainObject

Returns the value of attribute invocation_chain.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def invocation_chain
  @invocation_chain
end

#jobHash

Returns options used for executing capistrano task.

Returns:

  • (Hash)

    options used for executing capistrano task



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 19

class CelluloidWorker
  include CapistranoMulticonfigParallel::BaseActorHelper
  class TaskFailed < StandardError; end

  attr_accessor :job, :manager, :job_id, :app_name, :env_name, :action_name, :env_options, :machine, :client, :task_argv,
                :rake_tasks, :current_task_number, # tracking tasks
                :successfull_subscription, :subscription_channel, :publisher_channel, # for subscriptions and publishing events
                :job_termination_condition, :worker_state, :invocation_chain, :filename, :worker_log, :exit_status

  def work(job, manager)
    @job = job
    @job_id = job.id
    @worker_state = job.status
    @manager = manager
    @job_confirmation_conditions = []
    log_to_file("worker #{@job_id} received #{job.inspect}")
    @subscription_channel = "worker_#{@job_id}"
    @machine = CapistranoMulticonfigParallel::StateMachine.new(@job, Actor.current)
    @manager.setup_worker_conditions(@job)
    manager.register_worker_for_job(job, Actor.current)
  end

  def worker_state
    if Actor.current.alive?
      @machine.state.to_s.green
    else
      job.status = 'dead'
      job.status.upcase.red
    end
  end

  def start_task
    log_to_file("exec worker #{@job_id} starts task")
    @client = CelluloidPubsub::Client.new(actor: Actor.current, enable_debug: debug_websocket?, channel: subscription_channel, log_file_path: websocket_config.fetch('log_file_path', nil))
  end

  def publish_rake_event(data)
    @client.publish(rake_actor_id(data), data)
  end

  def rake_actor_id(_data)
    "rake_worker_#{@job_id}"
  end

  def on_message(message)
    log_to_file("worker #{@job_id} received:  #{message.inspect}")
    if @client.succesfull_subscription?(message)
      @successfull_subscription = true
      execute_after_succesfull_subscription
    else
      handle_subscription(message)
    end
  end

  def execute_after_succesfull_subscription
    async.execute_deploy
    @manager.async.wait_task_confirmations_worker(@job)
  end

  def rake_tasks
    @rake_tasks ||= []
  end

  def invocation_chain
    @invocation_chain ||= []
  end

  def execute_deploy
    log_to_file("invocation chain #{@job_id} is : #{@rake_tasks.inspect}")
    check_child_proces
    command = job.command.to_s
    log_to_file("worker #{@job_id} executes: #{command}")
    @child_process.async.work(@job, command, actor: Actor.current, silent: true)
  end

  def check_child_proces
    @child_process = CapistranoMulticonfigParallel::ChildProcess.new
    Actor.current.link @child_process
    @child_process
  end

  def on_close(code, reason)
    log_to_file("worker #{@job_id} websocket connection closed: #{code.inspect}, #{reason.inspect}")
  end

  def check_gitflow
    return if @job.stage != 'staging' || !@manager.can_tag_staging? || !executed_task?(CapistranoMulticonfigParallel::GITFLOW_TAG_STAGING_TASK)
    @manager.dispatch_new_job(@job, stage: 'production')
  end

  def handle_subscription(message)
    if message_is_about_a_task?(message)
      check_gitflow
      save_tasks_to_be_executed(message)
      async.update_machine_state(message['task']) # if message['action'] == 'invoke'
      log_to_file("worker #{@job_id} state is #{@machine.state}")
      task_approval(message)
    elsif message_is_for_stdout?(message)
      result = Celluloid::Actor[:terminal_server].show_confirmation(message['question'], message['default'])
      publish_rake_event(message.merge('action' => 'stdin', 'result' => result, 'client_action' => 'stdin'))
    else
      log_to_file(message, @job_id)
    end
  end

  def executed_task?(task)
    rake_tasks.present? && rake_tasks.index(task.to_s).present?
  end

  def task_approval(message)
    job_conditions = @manager.job_to_condition[@job_id]
    if job_conditions.present? && configuration.task_confirmations.include?(message['task']) && message['action'] == 'invoke'
      task_confirmation = job_conditions[message['task']]
      task_confirmation[:status] = 'confirmed'
      task_confirmation[:condition].signal(message['task'])
    else
      publish_rake_event(message.merge('approved' => 'yes'))
    end
  end

  def save_tasks_to_be_executed(message)
    log_to_file("worler #{@job_id} current invocation chain : #{rake_tasks.inspect}")
    rake_tasks << message['task'] if rake_tasks.last != message['task']
    invocation_chain << message['task'] if invocation_chain.last != message['task']
  end

  def update_machine_state(name)
    log_to_file("worker #{@job_id} triest to transition from #{@machine.state} to  #{name}")
    @machine.go_to_transition(name.to_s)
    error_message = "worker #{@job_id} task #{name} failed "
    raise(CapistranoMulticonfigParallel::CelluloidWorker::TaskFailed.new(error_message), error_message) if job.failed? # force worker to rollback
  end

  def send_msg(channel, message = nil)
    publish channel, message.present? && message.is_a?(Hash) ? { job_id: @job_id }.merge(message) : { job_id: @job_id, time: Time.now }
  end

  def finish_worker(exit_status)
    log_to_file("worker #{job_id} tries to terminate with exit_status #{exit_status}")
    @manager.mark_completed_remaining_tasks(@job) if Actor.current.alive?
    update_machine_state('FINISHED') if exit_status == 0
    @manager.workers_terminated.signal('completed') if @manager.present? && @manager.alive? && @manager.all_workers_finished?
  end

  def notify_finished(exit_status)
    finish_worker(exit_status)
    return if exit_status == 0
    error_message = "worker #{@job_id} task  failed with exit status #{exit_status.inspect}  "
    raise(CapistranoMulticonfigParallel::CelluloidWorker::TaskFailed.new(error_message), error_message)
  end
end

#job_idObject

Returns the value of attribute job_id.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def job_id
  @job_id
end

#job_termination_conditionObject

Returns the value of attribute job_termination_condition.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def job_termination_condition
  @job_termination_condition
end

#machineObject

Returns the value of attribute machine.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def machine
  @machine
end

#managerCapistranoMulticonfigParallel::CelluloidManager

Returns the instance of the manager that delegated the job to this worker.

Returns:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 19

class CelluloidWorker
  include CapistranoMulticonfigParallel::BaseActorHelper
  class TaskFailed < StandardError; end

  attr_accessor :job, :manager, :job_id, :app_name, :env_name, :action_name, :env_options, :machine, :client, :task_argv,
                :rake_tasks, :current_task_number, # tracking tasks
                :successfull_subscription, :subscription_channel, :publisher_channel, # for subscriptions and publishing events
                :job_termination_condition, :worker_state, :invocation_chain, :filename, :worker_log, :exit_status

  def work(job, manager)
    @job = job
    @job_id = job.id
    @worker_state = job.status
    @manager = manager
    @job_confirmation_conditions = []
    log_to_file("worker #{@job_id} received #{job.inspect}")
    @subscription_channel = "worker_#{@job_id}"
    @machine = CapistranoMulticonfigParallel::StateMachine.new(@job, Actor.current)
    @manager.setup_worker_conditions(@job)
    manager.register_worker_for_job(job, Actor.current)
  end

  def worker_state
    if Actor.current.alive?
      @machine.state.to_s.green
    else
      job.status = 'dead'
      job.status.upcase.red
    end
  end

  def start_task
    log_to_file("exec worker #{@job_id} starts task")
    @client = CelluloidPubsub::Client.new(actor: Actor.current, enable_debug: debug_websocket?, channel: subscription_channel, log_file_path: websocket_config.fetch('log_file_path', nil))
  end

  def publish_rake_event(data)
    @client.publish(rake_actor_id(data), data)
  end

  def rake_actor_id(_data)
    "rake_worker_#{@job_id}"
  end

  def on_message(message)
    log_to_file("worker #{@job_id} received:  #{message.inspect}")
    if @client.succesfull_subscription?(message)
      @successfull_subscription = true
      execute_after_succesfull_subscription
    else
      handle_subscription(message)
    end
  end

  def execute_after_succesfull_subscription
    async.execute_deploy
    @manager.async.wait_task_confirmations_worker(@job)
  end

  def rake_tasks
    @rake_tasks ||= []
  end

  def invocation_chain
    @invocation_chain ||= []
  end

  def execute_deploy
    log_to_file("invocation chain #{@job_id} is : #{@rake_tasks.inspect}")
    check_child_proces
    command = job.command.to_s
    log_to_file("worker #{@job_id} executes: #{command}")
    @child_process.async.work(@job, command, actor: Actor.current, silent: true)
  end

  def check_child_proces
    @child_process = CapistranoMulticonfigParallel::ChildProcess.new
    Actor.current.link @child_process
    @child_process
  end

  def on_close(code, reason)
    log_to_file("worker #{@job_id} websocket connection closed: #{code.inspect}, #{reason.inspect}")
  end

  def check_gitflow
    return if @job.stage != 'staging' || !@manager.can_tag_staging? || !executed_task?(CapistranoMulticonfigParallel::GITFLOW_TAG_STAGING_TASK)
    @manager.dispatch_new_job(@job, stage: 'production')
  end

  def handle_subscription(message)
    if message_is_about_a_task?(message)
      check_gitflow
      save_tasks_to_be_executed(message)
      async.update_machine_state(message['task']) # if message['action'] == 'invoke'
      log_to_file("worker #{@job_id} state is #{@machine.state}")
      task_approval(message)
    elsif message_is_for_stdout?(message)
      result = Celluloid::Actor[:terminal_server].show_confirmation(message['question'], message['default'])
      publish_rake_event(message.merge('action' => 'stdin', 'result' => result, 'client_action' => 'stdin'))
    else
      log_to_file(message, @job_id)
    end
  end

  def executed_task?(task)
    rake_tasks.present? && rake_tasks.index(task.to_s).present?
  end

  def task_approval(message)
    job_conditions = @manager.job_to_condition[@job_id]
    if job_conditions.present? && configuration.task_confirmations.include?(message['task']) && message['action'] == 'invoke'
      task_confirmation = job_conditions[message['task']]
      task_confirmation[:status] = 'confirmed'
      task_confirmation[:condition].signal(message['task'])
    else
      publish_rake_event(message.merge('approved' => 'yes'))
    end
  end

  def save_tasks_to_be_executed(message)
    log_to_file("worler #{@job_id} current invocation chain : #{rake_tasks.inspect}")
    rake_tasks << message['task'] if rake_tasks.last != message['task']
    invocation_chain << message['task'] if invocation_chain.last != message['task']
  end

  def update_machine_state(name)
    log_to_file("worker #{@job_id} triest to transition from #{@machine.state} to  #{name}")
    @machine.go_to_transition(name.to_s)
    error_message = "worker #{@job_id} task #{name} failed "
    raise(CapistranoMulticonfigParallel::CelluloidWorker::TaskFailed.new(error_message), error_message) if job.failed? # force worker to rollback
  end

  def send_msg(channel, message = nil)
    publish channel, message.present? && message.is_a?(Hash) ? { job_id: @job_id }.merge(message) : { job_id: @job_id, time: Time.now }
  end

  def finish_worker(exit_status)
    log_to_file("worker #{job_id} tries to terminate with exit_status #{exit_status}")
    @manager.mark_completed_remaining_tasks(@job) if Actor.current.alive?
    update_machine_state('FINISHED') if exit_status == 0
    @manager.workers_terminated.signal('completed') if @manager.present? && @manager.alive? && @manager.all_workers_finished?
  end

  def notify_finished(exit_status)
    finish_worker(exit_status)
    return if exit_status == 0
    error_message = "worker #{@job_id} task  failed with exit status #{exit_status.inspect}  "
    raise(CapistranoMulticonfigParallel::CelluloidWorker::TaskFailed.new(error_message), error_message)
  end
end

#publisher_channelObject

Returns the value of attribute publisher_channel.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def publisher_channel
  @publisher_channel
end

#rake_tasksObject

Returns the value of attribute rake_tasks.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def rake_tasks
  @rake_tasks
end

#subscription_channelObject

Returns the value of attribute subscription_channel.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def subscription_channel
  @subscription_channel
end

#successfull_subscriptionObject

Returns the value of attribute successfull_subscription.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def successfull_subscription
  @successfull_subscription
end

#task_argvObject

Returns the value of attribute task_argv.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def task_argv
  @task_argv
end

#worker_logObject

Returns the value of attribute worker_log.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def worker_log
  @worker_log
end

#worker_stateObject

Returns the value of attribute worker_state.



23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 23

def worker_state
  @worker_state
end

Instance Method Details

#check_child_procesObject



94
95
96
97
98
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 94

def check_child_proces
  @child_process = CapistranoMulticonfigParallel::ChildProcess.new
  Actor.current.link @child_process
  @child_process
end

#check_gitflowObject



104
105
106
107
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 104

def check_gitflow
  return if @job.stage != 'staging' || !@manager.can_tag_staging? || !executed_task?(CapistranoMulticonfigParallel::GITFLOW_TAG_STAGING_TASK)
  @manager.dispatch_new_job(@job, stage: 'production')
end

#execute_after_succesfull_subscriptionObject



73
74
75
76
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 73

def execute_after_succesfull_subscription
  async.execute_deploy
  @manager.async.wait_task_confirmations_worker(@job)
end

#execute_deployObject



86
87
88
89
90
91
92
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 86

def execute_deploy
  log_to_file("invocation chain #{@job_id} is : #{@rake_tasks.inspect}")
  check_child_proces
  command = job.command.to_s
  log_to_file("worker #{@job_id} executes: #{command}")
  @child_process.async.work(@job, command, actor: Actor.current, silent: true)
end

#executed_task?(task) ⇒ Boolean

Returns:

  • (Boolean)


124
125
126
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 124

def executed_task?(task)
  rake_tasks.present? && rake_tasks.index(task.to_s).present?
end

#finish_worker(exit_status) ⇒ Object



156
157
158
159
160
161
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 156

def finish_worker(exit_status)
  log_to_file("worker #{job_id} tries to terminate with exit_status #{exit_status}")
  @manager.mark_completed_remaining_tasks(@job) if Actor.current.alive?
  update_machine_state('FINISHED') if exit_status == 0
  @manager.workers_terminated.signal('completed') if @manager.present? && @manager.alive? && @manager.all_workers_finished?
end

#handle_subscription(message) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 109

def handle_subscription(message)
  if message_is_about_a_task?(message)
    check_gitflow
    save_tasks_to_be_executed(message)
    async.update_machine_state(message['task']) # if message['action'] == 'invoke'
    log_to_file("worker #{@job_id} state is #{@machine.state}")
    task_approval(message)
  elsif message_is_for_stdout?(message)
    result = Celluloid::Actor[:terminal_server].show_confirmation(message['question'], message['default'])
    publish_rake_event(message.merge('action' => 'stdin', 'result' => result, 'client_action' => 'stdin'))
  else
    log_to_file(message, @job_id)
  end
end

#notify_finished(exit_status) ⇒ Object



163
164
165
166
167
168
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 163

def notify_finished(exit_status)
  finish_worker(exit_status)
  return if exit_status == 0
  error_message = "worker #{@job_id} task  failed with exit status #{exit_status.inspect}  "
  raise(CapistranoMulticonfigParallel::CelluloidWorker::TaskFailed.new(error_message), error_message)
end

#on_close(code, reason) ⇒ Object



100
101
102
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 100

def on_close(code, reason)
  log_to_file("worker #{@job_id} websocket connection closed: #{code.inspect}, #{reason.inspect}")
end

#on_message(message) ⇒ Object



63
64
65
66
67
68
69
70
71
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 63

def on_message(message)
  log_to_file("worker #{@job_id} received:  #{message.inspect}")
  if @client.succesfull_subscription?(message)
    @successfull_subscription = true
    execute_after_succesfull_subscription
  else
    handle_subscription(message)
  end
end

#publish_rake_event(data) ⇒ Object



55
56
57
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 55

def publish_rake_event(data)
  @client.publish(rake_actor_id(data), data)
end

#rake_actor_id(_data) ⇒ Object



59
60
61
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 59

def rake_actor_id(_data)
  "rake_worker_#{@job_id}"
end

#save_tasks_to_be_executed(message) ⇒ Object



139
140
141
142
143
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 139

def save_tasks_to_be_executed(message)
  log_to_file("worler #{@job_id} current invocation chain : #{rake_tasks.inspect}")
  rake_tasks << message['task'] if rake_tasks.last != message['task']
  invocation_chain << message['task'] if invocation_chain.last != message['task']
end

#send_msg(channel, message = nil) ⇒ Object



152
153
154
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 152

def send_msg(channel, message = nil)
  publish channel, message.present? && message.is_a?(Hash) ? { job_id: @job_id }.merge(message) : { job_id: @job_id, time: Time.now }
end

#start_taskObject



50
51
52
53
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 50

def start_task
  log_to_file("exec worker #{@job_id} starts task")
  @client = CelluloidPubsub::Client.new(actor: Actor.current, enable_debug: debug_websocket?, channel: subscription_channel, log_file_path: websocket_config.fetch('log_file_path', nil))
end

#task_approval(message) ⇒ Object



128
129
130
131
132
133
134
135
136
137
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 128

def task_approval(message)
  job_conditions = @manager.job_to_condition[@job_id]
  if job_conditions.present? && configuration.task_confirmations.include?(message['task']) && message['action'] == 'invoke'
    task_confirmation = job_conditions[message['task']]
    task_confirmation[:status] = 'confirmed'
    task_confirmation[:condition].signal(message['task'])
  else
    publish_rake_event(message.merge('approved' => 'yes'))
  end
end

#update_machine_state(name) ⇒ Object



145
146
147
148
149
150
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 145

def update_machine_state(name)
  log_to_file("worker #{@job_id} triest to transition from #{@machine.state} to  #{name}")
  @machine.go_to_transition(name.to_s)
  error_message = "worker #{@job_id} task #{name} failed "
  raise(CapistranoMulticonfigParallel::CelluloidWorker::TaskFailed.new(error_message), error_message) if job.failed? # force worker to rollback
end

#work(job, manager) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb', line 28

def work(job, manager)
  @job = job
  @job_id = job.id
  @worker_state = job.status
  @manager = manager
  @job_confirmation_conditions = []
  log_to_file("worker #{@job_id} received #{job.inspect}")
  @subscription_channel = "worker_#{@job_id}"
  @machine = CapistranoMulticonfigParallel::StateMachine.new(@job, Actor.current)
  @manager.setup_worker_conditions(@job)
  manager.register_worker_for_job(job, Actor.current)
end