Class: Puma::Cluster::Worker
- Inherits:
-
Object
- Object
- Puma::Cluster::Worker
- Defined in:
- lib/puma/cluster.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#last_checkin ⇒ Object
readonly
Returns the value of attribute last_checkin.
-
#phase ⇒ Object
readonly
Returns the value of attribute phase.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#signal ⇒ Object
readonly
Returns the value of attribute signal.
Instance Method Summary collapse
- #boot! ⇒ Object
- #booted? ⇒ Boolean
- #hup ⇒ Object
-
#initialize(idx, pid, phase) ⇒ Worker
constructor
A new instance of Worker.
- #kill ⇒ Object
- #ping! ⇒ Object
- #ping_timeout?(which) ⇒ Boolean
- #term ⇒ Object
Constructor Details
#initialize(idx, pid, phase) ⇒ Worker
Returns a new instance of Worker.
46 47 48 49 50 51 52 53 |
# File 'lib/puma/cluster.rb', line 46 def initialize(idx, pid, phase) @index = idx @pid = pid @phase = phase @stage = :started @signal = "TERM" @last_checkin = Time.now end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
55 56 57 |
# File 'lib/puma/cluster.rb', line 55 def index @index end |
#last_checkin ⇒ Object (readonly)
Returns the value of attribute last_checkin.
55 56 57 |
# File 'lib/puma/cluster.rb', line 55 def last_checkin @last_checkin end |
#phase ⇒ Object (readonly)
Returns the value of attribute phase.
55 56 57 |
# File 'lib/puma/cluster.rb', line 55 def phase @phase end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
55 56 57 |
# File 'lib/puma/cluster.rb', line 55 def pid @pid end |
#signal ⇒ Object (readonly)
Returns the value of attribute signal.
55 56 57 |
# File 'lib/puma/cluster.rb', line 55 def signal @signal end |
Instance Method Details
#boot! ⇒ Object
61 62 63 64 |
# File 'lib/puma/cluster.rb', line 61 def boot! @last_checkin = Time.now @stage = :booted end |
#booted? ⇒ Boolean
57 58 59 |
# File 'lib/puma/cluster.rb', line 57 def booted? @stage == :booted end |
#hup ⇒ Object
92 93 94 95 |
# File 'lib/puma/cluster.rb', line 92 def hup Process.kill "HUP", @pid rescue Errno::ESRCH end |
#kill ⇒ Object
87 88 89 90 |
# File 'lib/puma/cluster.rb', line 87 def kill Process.kill "KILL", @pid rescue Errno::ESRCH end |
#ping! ⇒ Object
66 67 68 |
# File 'lib/puma/cluster.rb', line 66 def ping! @last_checkin = Time.now end |
#ping_timeout?(which) ⇒ Boolean
70 71 72 |
# File 'lib/puma/cluster.rb', line 70 def ping_timeout?(which) Time.now - @last_checkin > which end |
#term ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/puma/cluster.rb', line 74 def term begin if @first_term_sent && (Time.new - @first_term_sent) > 30 @signal = "KILL" else @first_term_sent ||= Time.new end Process.kill @signal, @pid rescue Errno::ESRCH end end |