Class: Puma::Cluster::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/puma/cluster.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pid, phase) ⇒ Worker

Returns a new instance of Worker.



32
33
34
35
36
37
# File 'lib/puma/cluster.rb', line 32

def initialize(pid, phase)
  @pid = pid
  @phase = phase
  @stage = :started
  @signal = "TERM"
end

Instance Attribute Details

#phaseObject (readonly)

Returns the value of attribute phase.



39
40
41
# File 'lib/puma/cluster.rb', line 39

def phase
  @phase
end

#pidObject (readonly)

Returns the value of attribute pid.



39
40
41
# File 'lib/puma/cluster.rb', line 39

def pid
  @pid
end

#signalObject (readonly)

Returns the value of attribute signal.



39
40
41
# File 'lib/puma/cluster.rb', line 39

def signal
  @signal
end

Instance Method Details

#boot!Object



45
46
47
# File 'lib/puma/cluster.rb', line 45

def boot!
  @stage = :booted
end

#booted?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/puma/cluster.rb', line 41

def booted?
  @stage == :booted
end

#termObject



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/puma/cluster.rb', line 49

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