lib/ustate/graphite.rb in ustate-client-0.0.4 vs lib/ustate/graphite.rb in ustate-client-0.0.5
- old
+ new
@@ -13,10 +13,11 @@
def initialize(index, opts = {})
@index = index
@query = opts[:query]
@host = opts[:host] || HOST
@port = opts[:port] || PORT
+ @server = opts[:server]
@interval = opts[:interval] || INTERVAL
@locket = Mutex.new
start
end
@@ -66,13 +67,18 @@
end
def start
@runner = Thread.new do
loop do
- @index.query(Query.new(string: @query)).each do |state|
- forward state
+ begin
+ @index.query(Query.new(string: @query)).each do |state|
+ forward state
+ end
+ sleep @interval
+ rescue Exception => e
+ @server.log.warn e
+ sleep 1
end
- sleep @interval
end
end
end
def with_connection