riemann-babbler 1.1.7 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,6 +28,7 @@ class Riemann::Babbler::Starter
28
28
  set_logger_lvl
29
29
  load_plugins
30
30
  $riemann = get_riemann
31
+ Riemann::Responder.new.start
31
32
  start_plugins!
32
33
  end
33
34
 
@@ -1,19 +1,32 @@
1
1
  require 'socket'
2
2
  require 'json'
3
3
 
4
- server = TCPServer.open(55755)
4
+ class Riemann::Responder
5
+ INFO = {
6
+ :version => Riemann::Babbler::VERSION,
7
+ :ruby => "#{RUBY_VERSION}-#{RUBY_PATCHLEVEL}"
8
+ }.freeze
5
9
 
6
- info = {
7
- :version => Riemann::Babbler::VERSION,
8
- :ruby => "#{RUBY_VERSION}-#{RUBY_PATCHLEVEL}"
9
- }
10
+ def initialize( port = 55755 )
11
+ @port = port
12
+ end
10
13
 
11
- t = Thread.new {
12
- loop {
13
- client = server.accept
14
- client.puts info.to_json
15
- client.close
16
- }
17
- }
14
+ def start
15
+ @worker_thread = Thread.new {
16
+ Socket.tcp_server_loop(@port) do |sock, _|
17
+ begin
18
+ sock.puts INFO.to_json
19
+ ensure
20
+ sock.close
21
+ end
22
+ end
23
+ }
24
+ end
18
25
 
19
- t.join
26
+ def stop
27
+ if @worker_thread
28
+ @worker_thread.kill
29
+ @worker_thread = nil
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
1
  module Riemann
2
2
  class Babbler
3
- VERSION = '1.1.7'
3
+ VERSION = '1.1.9'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riemann-babbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.1.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: