34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/simple_metrics/udp_server.rb', line 34
def start
SimpleMetrics.logger.info "SERVER: starting up on #{host}:#{port}..."
trap('TERM') { stop }
trap('INT') { stop }
DataPointRepository.ensure_collections_exist
EM.run do
EM.open_datagram_socket(host, port, SimpleMetrics::ClientHandler) do |con|
EventMachine::add_periodic_timer(flush_interval) do
SimpleMetrics.logger.debug "SERVER: period timer triggered after #{flush_interval} seconds"
EM.defer { SimpleMetrics::Importer.flush_raw(ClientHandler.get_and_clear_data) }
end
end
end
end
|