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.
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/puma/cluster.rb', line 64 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.
77 78 79 |
# File 'lib/puma/cluster.rb', line 77 def index @index end |
#last_checkin ⇒ Object (readonly)
Returns the value of attribute last_checkin.
77 78 79 |
# File 'lib/puma/cluster.rb', line 77 def last_checkin @last_checkin end |
#last_status ⇒ Object (readonly)
Returns the value of attribute last_status.
77 78 79 |
# File 'lib/puma/cluster.rb', line 77 def last_status @last_status end |
#phase ⇒ Object (readonly)
Returns the value of attribute phase.
77 78 79 |
# File 'lib/puma/cluster.rb', line 77 def phase @phase end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
77 78 79 |
# File 'lib/puma/cluster.rb', line 77 def pid @pid end |
#signal ⇒ Object (readonly)
Returns the value of attribute signal.
77 78 79 |
# File 'lib/puma/cluster.rb', line 77 def signal @signal end |
Instance Method Details
#boot! ⇒ Object
83 84 85 86 |
# File 'lib/puma/cluster.rb', line 83 def boot! @last_checkin = Time.now @stage = :booted end |
#booted? ⇒ Boolean
79 80 81 |
# File 'lib/puma/cluster.rb', line 79 def booted? @stage == :booted end |
#dead! ⇒ Object
92 93 94 |
# File 'lib/puma/cluster.rb', line 92 def dead! @dead = true end |
#dead? ⇒ Boolean
88 89 90 |
# File 'lib/puma/cluster.rb', line 88 def dead? @dead end |
#hup ⇒ Object
123 124 125 126 |
# File 'lib/puma/cluster.rb', line 123 def hup Process.kill "HUP", @pid rescue Errno::ESRCH end |
#kill ⇒ Object
118 119 120 121 |
# File 'lib/puma/cluster.rb', line 118 def kill Process.kill "KILL", @pid rescue Errno::ESRCH end |
#ping!(status) ⇒ Object
96 97 98 99 |
# File 'lib/puma/cluster.rb', line 96 def ping!(status) @last_checkin = Time.now @last_status = status end |
#ping_timeout?(which) ⇒ Boolean
101 102 103 |
# File 'lib/puma/cluster.rb', line 101 def ping_timeout?(which) Time.now - @last_checkin > which end |
#term ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/puma/cluster.rb', line 105 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 |