123456789_123456789_123456789_123456789_123456789_

Class: Puma::Cluster::Worker

Relationships & Source Files
Inherits: Object
Defined in: lib/puma/cluster.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(idx, pid, phase, options) ⇒ Worker

[ GitHub ]

  
# File 'lib/puma/cluster.rb', line 64

def initialize(idx, pid, phase, options)
  @index = idx
  @pid = pid
  @phase = phase
  @stage = :started
  @signal = "TERM"
  @options = options
  @first_term_sent = nil
  @last_checkin = Time.now
  @last_status = '{}'
  @dead = false
end

Instance Attribute Details

#booted?Boolean (readonly)

[ GitHub ]

  
# File 'lib/puma/cluster.rb', line 79

def booted?
  @stage == :booted
end

#dead?Boolean (readonly)

[ GitHub ]

  
# File 'lib/puma/cluster.rb', line 88

def dead?
  @dead
end

#index (readonly)

[ GitHub ]

  
# File 'lib/puma/cluster.rb', line 77

attr_reader :index, :pid, :phase, :signal, :last_checkin, :last_status

#last_checkin (readonly)

[ GitHub ]

  
# File 'lib/puma/cluster.rb', line 77

attr_reader :index, :pid, :phase, :signal, :last_checkin, :last_status

#last_status (readonly)

[ GitHub ]

  
# File 'lib/puma/cluster.rb', line 77

attr_reader :index, :pid, :phase, :signal, :last_checkin, :last_status

#phase (readonly)

[ GitHub ]

  
# File 'lib/puma/cluster.rb', line 77

attr_reader :index, :pid, :phase, :signal, :last_checkin, :last_status

#pid (readonly)

[ GitHub ]

  
# File 'lib/puma/cluster.rb', line 77

attr_reader :index, :pid, :phase, :signal, :last_checkin, :last_status

#signal (readonly)

[ GitHub ]

  
# File 'lib/puma/cluster.rb', line 77

attr_reader :index, :pid, :phase, :signal, :last_checkin, :last_status

Instance Method Details

#boot!

[ GitHub ]

  
# File 'lib/puma/cluster.rb', line 83

def boot!
  @last_checkin = Time.now
  @stage = :booted
end

#dead!

[ GitHub ]

  
# File 'lib/puma/cluster.rb', line 92

def dead!
  @dead = true
end

#hup

[ GitHub ]

  
# File 'lib/puma/cluster.rb', line 123

def hup
  Process.kill "HUP", @pid
rescue Errno::ESRCH
end

#kill

[ GitHub ]

  
# File 'lib/puma/cluster.rb', line 118

def kill
  Process.kill "KILL", @pid
rescue Errno::ESRCH
end

#ping!(status)

[ GitHub ]

  
# File 'lib/puma/cluster.rb', line 96

def ping!(status)
  @last_checkin = Time.now
  @last_status = status
end

#ping_timeout?(which) ⇒ Boolean

[ GitHub ]

  
# File 'lib/puma/cluster.rb', line 101

def ping_timeout?(which)
  Time.now - @last_checkin > which
end

#term

[ GitHub ]

  
# 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