class Puma::Cluster::Worker

Attributes

index[R]
last_checkin[R]
last_status[R]
phase[R]
pid[R]
signal[R]
started_at[R]

Public Class Methods

new(idx, pid, phase, options) click to toggle source
# File lib/puma/cluster.rb, line 66
def initialize(idx, pid, phase, options)
  @index = idx
  @pid = pid
  @phase = phase
  @stage = :started
  @signal = "TERM"
  @options = options
  @first_term_sent = nil
  @started_at = Time.now
  @last_checkin = Time.now
  @last_status = '{}'
  @term = false
end

Public Instance Methods

boot!() click to toggle source
# File lib/puma/cluster.rb, line 86
def boot!
  @last_checkin = Time.now
  @stage = :booted
end
booted?() click to toggle source
# File lib/puma/cluster.rb, line 82
def booted?
  @stage == :booted
end
hup() click to toggle source
# File lib/puma/cluster.rb, line 122
def hup
  Process.kill "HUP", @pid
rescue Errno::ESRCH
end
kill() click to toggle source
# File lib/puma/cluster.rb, line 117
def kill
  Process.kill "KILL", @pid
rescue Errno::ESRCH
end
ping!(status) click to toggle source
# File lib/puma/cluster.rb, line 95
def ping!(status)
  @last_checkin = Time.now
  @last_status = status
end
ping_timeout?(which) click to toggle source
# File lib/puma/cluster.rb, line 100
def ping_timeout?(which)
  Time.now - @last_checkin > which
end
term() click to toggle source
# File lib/puma/cluster.rb, line 104
def term
  begin
    if @first_term_sent && (Time.now - @first_term_sent) > @options[:worker_shutdown_timeout]
      @signal = "KILL"
    else
      @term ||= true
      @first_term_sent ||= Time.now
    end
    Process.kill @signal, @pid
  rescue Errno::ESRCH
  end
end
term?() click to toggle source
# File lib/puma/cluster.rb, line 91
def term?
  @term
end