Mercurial > code > home > repos > homeauto
diff service/collector/sse_collector.py @ 442:ee74dc3b58fb
collector build improvements; stats and logging
Ignore-this: 22fbbb2cde6a6bdbd9d0017f1f157a41
author | drewp@bigasterisk.com |
---|---|
date | Thu, 18 Apr 2019 09:15:39 -0700 |
parents | 124c921ad52d |
children | 2f7bc2ecf6b5 |
line wrap: on
line diff
--- a/service/collector/sse_collector.py Thu Apr 18 09:15:22 2019 -0700 +++ b/service/collector/sse_collector.py Thu Apr 18 09:15:39 2019 -0700 @@ -12,7 +12,7 @@ no_setup() import sys, logging, collections, json, time -from twisted.internet import reactor +from twisted.internet import reactor, defer import cyclone.web, cyclone.sse from rdflib import URIRef, Namespace from docopt import docopt @@ -260,6 +260,7 @@ for source in sources: if source not in self.clients and source != COLLECTOR: + log.debug('connect to patch source %s', source) self._localStatements.setSourceState(source, ROOM['connect']) self.clients[source] = ReconnectingPatchSource( source, listener=lambda p, fullGraph, source=source: self._onPatch( @@ -268,9 +269,7 @@ def removeSseHandler(self, handler): log.info('removeSseHandler %r', handler) - self.statements.discardHandler(handler) - for source in self._sourcesForHandler(handler): for otherHandler in self.handlers: if (otherHandler != handler and @@ -347,11 +346,13 @@ if arg['-v']: import twisted.python.log twisted.python.log.startLogging(sys.stdout) - log.setLevel(logging.INFO) + log.setLevel(logging.DEBUG) + defer.setDebugging(True) graphClients = GraphClients() - + #exporter = InfluxExporter(... to export some stats values + reactor.listenTCP( 9072, cyclone.web.Application( @@ -359,6 +360,7 @@ (r'/', Root), (r'/state', State), (r'/graph/(.*)', SomeGraph), + (r'/stats/(.*)', StatsHandler, {'serverName': 'collector'}), ], graphClients=graphClients), interface='::')