Sha256: ae403760bb89e1e6cbdf9c30e8199328545249b137066ca1dffcef19bfe52382

Contents?: true

Size: 616 Bytes

Versions: 1

Compression:

Stored size: 616 Bytes

Contents

# encoding: utf-8
require "logstash/devutils/rspec/spec_helper"
require 'logstash/inputs/unix'

class UnixSocketHelper

  attr_reader :path

  def initialize
    @socket = nil
  end

  def new_socket(path)
    @path   = path
    File.unlink if File.exists?(path) && File.socket?(path)
    @socket = UNIXServer.new(path)
    self
  end

  def loop(forever=false)
    @thread = Thread.new do
      begin
        s = @socket.accept
        s.puts "hi" while forever
      rescue Errno::EPIPE
        # ...
      end
    end
    self
  end

  def close
    @thread.kill
    @socket.close
    File.unlink(path)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logstash-input-unix-2.0.2 spec/spec_helper.rb