Class: SimpleWorker::LocalWorker

Inherits:
AbstractListener show all
Defined in:
lib/simpleworker/local_worker.rb

Constant Summary collapse

DEFAULT_CMD =
['/bin/bash', '-l', 'bundle', 'exec', 'rake']

Instance Method Summary collapse

Methods inherited from AbstractListener

#on_interrupted, #on_log, #on_node_start, #on_node_stop, #on_task_active, #on_task_expire, #on_task_start, #on_task_stop, #on_timeout, #update

Constructor Details

#initialize(*args) ⇒ LocalWorker

Returns a new instance of LocalWorker.



7
8
9
10
11
12
# File 'lib/simpleworker/local_worker.rb', line 7

def initialize(*args)
  cmd = args
  cmd = DEFAULT_CMD if cmd.empty?
  @process = ChildProcess.build(*cmd)
  @process.io.inherit!
end

Instance Method Details

#on_start(jobid) ⇒ Object

Start a subprocess with the environment variable ‘JOBID’ set to the current jobid.



16
17
18
19
# File 'lib/simpleworker/local_worker.rb', line 16

def on_start(jobid)
  @process.environment['JOBID'] = jobid
  @process.start
end

#on_stopObject



21
22
23
# File 'lib/simpleworker/local_worker.rb', line 21

def on_stop
  @process.stop
end