Class: Batsd::Server::Daemon

Inherits:
Object
  • Object
show all
Defined in:
lib/batsd/server.rb

Overview

Bind to port+2 and serve up data over TCP. Offers access to both the set of datapoints and the values as JSON arrays.

Instance Method Summary (collapse)

Constructor Details

- (Daemon) initialize(options = {})

Create a new daemon and expose options



75
76
77
78
79
80
# File 'lib/batsd/server.rb', line 75

def initialize(options={})
  @options = options
  @bind = @options[:bind] || '0.0.0.0'
  @port = (@options[:port] || 8125) + 2
  Batsd::Server.config = @options.merge(port: @port)
end

Instance Method Details

- (Object) run

Run the server



83
84
85
86
87
88
# File 'lib/batsd/server.rb', line 83

def run
  EventMachine.threadpool_size = 100
  EventMachine::run do
    EventMachine::start_server(@bind, @port, Batsd::Server)  
  end
end