Sha256: 397ae7abf13e9a8f935c10b4494bc3de2e3d13bbd6677d6cf57f4e4c4d55e532

Contents?: true

Size: 703 Bytes

Versions: 22

Compression:

Stored size: 703 Bytes

Contents

module Kuroko2
  module Command
    class Kill
      def initialize(host, process = nil)
        @hostname = host
        @process  = process
      end

      def execute
        if (signal = ProcessSignal.poll(@hostname))
          Kuroko2.logger.info("[#{@hostname}-#{@process}] Send #{Signal.signame(signal.number)} signal to #{signal.pid}")
          Process.kill(signal.number, signal.pid)

          signal.destroy!
          signal
        end
      rescue SystemCallError => e
        signal.update_column(:message, "[#{@hostname}-#{@process}] #{e.class}: #{e.message}") rescue nil

        Kuroko2.logger.error("[#{@hostname}-#{@process}] #{e.class}: #{e.message}")
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
kuroko2-0.2.1 lib/kuroko2/command/kill.rb
kuroko2-0.2.0 lib/kuroko2/command/kill.rb