Class: StatsdListener
- Inherits:
-
Object
- Object
- StatsdListener
- Includes:
- Term::ANSIColor
- Defined in:
- lib/statsd_listener.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ StatsdListener
constructor
A new instance of StatsdListener.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ StatsdListener
Returns a new instance of StatsdListener.
14 15 16 17 18 19 20 21 |
# File 'lib/statsd_listener.rb', line 14 def initialize(args) $stdout.sync = true @socket = UDPSocket.new @port = PortSanitizer.get_port(args) @socket.bind(nil, @port) end |
Class Method Details
.run(args) ⇒ Object
8 9 10 11 12 |
# File 'lib/statsd_listener.rb', line 8 def self.run(args) puts "Starting MiniStatsd...\n\n" new(args).run end |
Instance Method Details
#run ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/statsd_listener.rb', line 23 def run puts "Listening on port #{@port}" while @message = @socket.recvfrom(@port) extract_metric print_metric end end |