summary refs log tree commit diff
path: root/synapse/app/homeserver.py
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2015-03-12 16:05:46 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2015-03-12 16:24:51 +0000
commitb98b4c135d9738d5cf701712fc244209651cddf7 (patch)
tree56f242ffc89722a96c1f89f18525c5d1966cef0b /synapse/app/homeserver.py
parentFold the slightly-odd bind_port/secure_port/etc.. logic into SynapseHomeServe... (diff)
downloadsynapse-b98b4c135d9738d5cf701712fc244209651cddf7.tar.xz
Option to serve metrics from their own localhost-only TCP port instead of muxed on the main listener
Diffstat (limited to 'synapse/app/homeserver.py')
-rwxr-xr-xsynapse/app/homeserver.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py
index 2ba701f53f..aa7c722efc 100755
--- a/synapse/app/homeserver.py
+++ b/synapse/app/homeserver.py
@@ -129,7 +129,8 @@ class SynapseHomeServer(HomeServer):
             location of the web client. This does nothing if web_client is not
             True.
         """
-        web_client = self.get_config().webclient
+        config = self.get_config()
+        web_client = config.webclient
 
         # list containing (path_str, Resource) e.g:
         # [ ("/aaa/bbb/cc", Resource1), ("/aaa/dummy", Resource2) ]
@@ -155,7 +156,7 @@ class SynapseHomeServer(HomeServer):
             self.root_resource = Resource()
 
         metrics_resource = self.get_resource_for_metrics()
-        if metrics_resource is not None:
+        if config.metrics_port is None and metrics_resource is not None:
             desired_tree.append((METRICS_PREFIX, metrics_resource))
 
         # ideally we'd just use getChild and putChild but getChild doesn't work
@@ -234,6 +235,13 @@ class SynapseHomeServer(HomeServer):
             )
             logger.info("Synapse now listening on port %d", config.unsecure_port)
 
+        metrics_resource = self.get_resource_for_metrics()
+        if metrics_resource and config.metrics_port is not None:
+            reactor.listenTCP(
+                config.metrics_port, Site(metrics_resource), interface="127.0.0.1",
+            )
+            logger.info("Metrics now running on 127.0.0.1 port %d", config.metrics_port)
+
 
 def get_version_string():
     try: