Class: Resque::Worker
- Inherits:
-
Object
- Object
- Resque::Worker
- Defined in:
- lib/resque/heartbeat.rb
Defined Under Namespace
Classes: Heart
Instance Method Summary collapse
- #dead? ⇒ Boolean
- #heart ⇒ Object
- #is_me? ⇒ Boolean
- #prune_if_dead ⇒ Object
- #remote_hostname ⇒ Object
- #remote_pid ⇒ Object
- #startup_with_heartbeat ⇒ Object (also: #startup)
- #unregister_worker_with_heartbeat(*args) ⇒ Object (also: #unregister_worker)
Instance Method Details
#dead? ⇒ Boolean
37 38 39 |
# File 'lib/resque/heartbeat.rb', line 37 def dead? return heart.dead? end |
#heart ⇒ Object
25 26 27 |
# File 'lib/resque/heartbeat.rb', line 25 def heart @heart ||= Heart.new(self) end |
#is_me? ⇒ Boolean
12 13 14 15 |
# File 'lib/resque/heartbeat.rb', line 12 def is_me? pieces = id.split(':') (pieces[0].casecmp(hostname)==0) && (pieces[1].to_i == Process.pid) end |
#prune_if_dead ⇒ Object
41 42 43 44 45 46 |
# File 'lib/resque/heartbeat.rb', line 41 def prune_if_dead return nil unless dead? Resque.logger.info "Pruning worker '#{remote_hostname}' from resque" unregister_worker end |
#remote_hostname ⇒ Object
29 30 31 |
# File 'lib/resque/heartbeat.rb', line 29 def remote_hostname @remote_hostname ||= id.split(':').first end |
#remote_pid ⇒ Object
33 34 35 |
# File 'lib/resque/heartbeat.rb', line 33 def remote_pid @remote_pid ||= id.split(':')[1] end |
#startup_with_heartbeat ⇒ Object Also known as: startup
6 7 8 9 |
# File 'lib/resque/heartbeat.rb', line 6 def startup_with_heartbeat startup_without_heartbeat heart.run end |
#unregister_worker_with_heartbeat(*args) ⇒ Object Also known as: unregister_worker
18 19 20 21 22 |
# File 'lib/resque/heartbeat.rb', line 18 def unregister_worker_with_heartbeat(*args) to_stop = is_me? ? heart : Heart.new(self) to_stop.stop unregister_worker_without_heartbeat(*args) end |