Class: Preforker::Worker::WorkerAPI
- Inherits:
-
Object
- Object
- Preforker::Worker::WorkerAPI
- Defined in:
- lib/preforker/worker.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(worker, master) ⇒ WorkerAPI
constructor
A new instance of WorkerAPI.
- #kill ⇒ Object
- #wants_me_alive? ⇒ Boolean
Constructor Details
#initialize(worker, master) ⇒ WorkerAPI
Returns a new instance of WorkerAPI.
9 10 11 12 13 14 15 |
# File 'lib/preforker/worker.rb', line 9 def initialize(worker, master) @master = master @logger = master.logger @worker = worker @alive = @worker.tmp @last_file_bit = 0 end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
7 8 9 |
# File 'lib/preforker/worker.rb', line 7 def logger @logger end |
Instance Method Details
#kill ⇒ Object
26 27 28 29 30 31 |
# File 'lib/preforker/worker.rb', line 26 def kill if @alive @worker.log "Exiting gracefully" @alive = false end end |
#wants_me_alive? ⇒ Boolean
17 18 19 20 21 22 23 24 |
# File 'lib/preforker/worker.rb', line 17 def wants_me_alive? if @alive #we are alive, let's be thankful and tell master we are alive and happy @last_file_bit = 0 == @last_file_bit ? 1 : 0 @alive.chmod(@last_file_bit) end @alive end |