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.
-
#last_status ⇒ Object
readonly
Returns the value of attribute last_status.
-
#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
- #dead! ⇒ Object
- #dead? ⇒ Boolean
- #hup ⇒ Object
-
#initialize(idx, pid, phase, options) ⇒ Worker
constructor
A new instance of Worker.
- #kill ⇒ Object
- #ping!(status) ⇒ Object
- #ping_timeout?(which) ⇒ Boolean
- #term ⇒ Object
Constructor Details
#initialize(idx, pid, phase, options) ⇒ Worker
Returns a new instance of Worker.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/puma/cluster.rb', line 46 def initialize(idx, pid, phase, ) @index = idx @pid = pid @phase = phase @stage = :started @signal = "TERM" @options = @first_term_sent = nil @last_checkin = Time.now @last_status = '{}' @dead = false end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
59 60 61 |
# File 'lib/puma/cluster.rb', line 59 def index @index end |
#last_checkin ⇒ Object (readonly)
Returns the value of attribute last_checkin.
59 60 61 |
# File 'lib/puma/cluster.rb', line 59 def last_checkin @last_checkin end |
#last_status ⇒ Object (readonly)
Returns the value of attribute last_status.
59 60 61 |
# File 'lib/puma/cluster.rb', line 59 def last_status @last_status end |
#phase ⇒ Object (readonly)
Returns the value of attribute phase.
59 60 61 |
# File 'lib/puma/cluster.rb', line 59 def phase @phase end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
59 60 61 |
# File 'lib/puma/cluster.rb', line 59 def pid @pid end |
#signal ⇒ Object (readonly)
Returns the value of attribute signal.
59 60 61 |
# File 'lib/puma/cluster.rb', line 59 def signal @signal end |
Instance Method Details
#boot! ⇒ Object
65 66 67 68 |
# File 'lib/puma/cluster.rb', line 65 def boot! @last_checkin = Time.now @stage = :booted end |
#booted? ⇒ Boolean
61 62 63 |
# File 'lib/puma/cluster.rb', line 61 def booted? @stage == :booted end |
#dead! ⇒ Object
74 75 76 |
# File 'lib/puma/cluster.rb', line 74 def dead! @dead = true end |
#dead? ⇒ Boolean
70 71 72 |
# File 'lib/puma/cluster.rb', line 70 def dead? @dead end |
#hup ⇒ Object
105 106 107 108 |
# File 'lib/puma/cluster.rb', line 105 def hup Process.kill "HUP", @pid rescue Errno::ESRCH end |
#kill ⇒ Object
100 101 102 103 |
# File 'lib/puma/cluster.rb', line 100 def kill Process.kill "KILL", @pid rescue Errno::ESRCH end |
#ping!(status) ⇒ Object
78 79 80 81 |
# File 'lib/puma/cluster.rb', line 78 def ping!(status) @last_checkin = Time.now @last_status = status end |
#ping_timeout?(which) ⇒ Boolean
83 84 85 |
# File 'lib/puma/cluster.rb', line 83 def ping_timeout?(which) Time.now - @last_checkin > which end |
#term ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/puma/cluster.rb', line 87 def term begin if @first_term_sent && (Time.now - @first_term_sent) > @options[:worker_shutdown_timeout] @signal = "KILL" else @first_term_sent ||= Time.now end Process.kill @signal, @pid rescue Errno::ESRCH end end |