Sha256: 32a25b25a959b9486c370640efb12996fbe0b322e6d5fb90089515d700bc5ab6

Contents?: true

Size: 552 Bytes

Versions: 4

Compression:

Stored size: 552 Bytes

Contents

require 'socket'
require 'json'

class Riemann::Responder

  INFO = {
      :version => Riemann::Babbler::VERSION,
      :ruby => "#{RUBY_VERSION}-#{RUBY_PATCHLEVEL}"
  }.freeze

  def initialize( port = 55755 )
    @port = port
  end

  def start
    @worker_thread = Thread.new {
      Socket.tcp_server_loop(@port) do |sock, _|
        begin
          sock.puts INFO.to_json
        ensure
          sock.close
        end
      end
    }
  end

  def stop
    if @worker_thread
      @worker_thread.kill
      @worker_thread = nil
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
riemann-babbler-1.2.4 lib/riemann/babbler/support/pinger.rb
riemann-babbler-1.2.3 lib/riemann/babbler/support/pinger.rb
riemann-babbler-1.2.2 lib/riemann/babbler/support/pinger.rb
riemann-babbler-1.2.1 lib/riemann/babbler/support/pinger.rb