Sha256: 207225abcac7437468360794d3f664de2ab194325d1a6f9d607011fa3954742a

Contents?: true

Size: 824 Bytes

Versions: 1

Compression:

Stored size: 824 Bytes

Contents

require 'socket'

module ::WorkerKiller
  module Killer
    class Puma < ::WorkerKiller::Killer::Base

      attr_accessor :ipc_path, :worker_num

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

      def do_kill(sig, pid, alive_sec, **_params)
        if sig == :KILL
          logger.error "#{self} force to kill self[#{worker_num}] (pid: #{pid}) alive: #{alive_sec} sec (trial #{kill_attempts})"
          Process.kill sig, pid
          return
        end

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

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

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
worker_killer-1.1.0.214146 lib/worker_killer/killer/puma.rb