Class: WorkerKiller::Killer::Puma

Inherits:
Base
  • Object
show all
Defined in:
lib/worker_killer/killer/puma.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#config, #kill_attempts

Instance Method Summary collapse

Methods inherited from Base

#kill, #logger

Constructor Details

#initialize(ipc_path:, worker_num: nil, **kwargs) ⇒ Puma

Returns a new instance of Puma.



9
10
11
12
13
# File 'lib/worker_killer/killer/puma.rb', line 9

def initialize(ipc_path:, worker_num: nil, **kwargs)
  super(**kwargs)
  @ipc_path = ipc_path
  @worker_num = worker_num
end

Instance Attribute Details

#ipc_pathObject

Returns the value of attribute ipc_path.



7
8
9
# File 'lib/worker_killer/killer/puma.rb', line 7

def ipc_path
  @ipc_path
end

#worker_numObject

Returns the value of attribute worker_num.



7
8
9
# File 'lib/worker_killer/killer/puma.rb', line 7

def worker_num
  @worker_num
end

Instance Method Details

#do_kill(sig, pid, alive_sec, **_params) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/worker_killer/killer/puma.rb', line 15

def do_kill(sig, pid, alive_sec, **_params)
  return if @already_sended == sig

  logger.warn "#{self} send #{worker_num} to Puma Plugin (pid: #{pid}) alive: #{alive_sec} sec (trial #{kill_attempts}) triggered by #{sig}"

  @already_sended = sig

  Socket.unix(ipc_path) do |sock|
    sock.puts Integer(worker_num).to_s
  end
end