Module: Bluth::WorkerBase::ClassMethods
- Defined in:
- lib/bluth/worker.rb
Instance Method Summary collapse
- #from_redis(wid) ⇒ Object
- #kill(pid_file) ⇒ Object
- #onexit(&blk) ⇒ Object
- #onstart(&blk) ⇒ Object
- #run(*args) ⇒ Object
- #run!(*args) ⇒ Object
-
#runblock(meth) ⇒ Object
A convenience method for calling onstart/onexit blocks.
Instance Method Details
#from_redis(wid) ⇒ Object
77 78 79 80 |
# File 'lib/bluth/worker.rb', line 77 def from_redis(wid) me = new nil, nil, wid super(me.index) end |
#kill(pid_file) ⇒ Object
93 94 95 96 97 |
# File 'lib/bluth/worker.rb', line 93 def kill(pid_file) self.class.runblock :onexit pid = read_pid_file pid_file super(pid_file, 10) end |
#onexit(&blk) ⇒ Object
102 103 104 105 |
# File 'lib/bluth/worker.rb', line 102 def onexit &blk @onexit = blk unless blk.nil? @onexit end |
#onstart(&blk) ⇒ Object
98 99 100 101 |
# File 'lib/bluth/worker.rb', line 98 def onstart &blk @onstart = blk unless blk.nil? @onstart end |
#run(*args) ⇒ Object
87 88 89 90 91 92 |
# File 'lib/bluth/worker.rb', line 87 def run(*args) me = new Familia.info "Created: #{me.rediskey}" me.run me end |
#run!(*args) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/bluth/worker.rb', line 81 def run!(*args) me = new Familia.info "Created: #{me.rediskey}" me.run! me end |
#runblock(meth) ⇒ Object
A convenience method for calling onstart/onexit blocks
107 108 109 110 111 |
# File 'lib/bluth/worker.rb', line 107 def runblock meth blk = self.send(meth) return if blk.nil? instance_eval &blk end |