Sha256: 5a1ac3f5d04386c3fbf61d729f24c64b1193290e8aa75a7a9ad7eb66f3b6272a

Contents?: true

Size: 701 Bytes

Versions: 1

Compression:

Stored size: 701 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)
        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

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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