Class: SimpleWorker::LocalWorker
- Inherits:
-
AbstractListener
- Object
- AbstractListener
- SimpleWorker::LocalWorker
- Defined in:
- lib/simpleworker/local_worker.rb
Constant Summary collapse
- DEFAULT_CMD =
['/bin/bash', '-l', 'bundle', 'exec', 'rake']
Instance Method Summary collapse
-
#initialize(*args) ⇒ LocalWorker
constructor
A new instance of LocalWorker.
-
#on_start(jobid) ⇒ Object
Start a subprocess with the environment variable ‘JOBID’ set to the current jobid.
- #on_stop ⇒ Object
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_stop ⇒ Object
21 22 23 |
# File 'lib/simpleworker/local_worker.rb', line 21 def on_stop @process.stop end |