summaryrefslogtreecommitdiffstats
path: root/keystone/common
diff options
context:
space:
mode:
authorDevin Carlen <devin.carlen@gmail.com>2012-03-03 14:01:46 -0800
committerDevin Carlen <devin.carlen@gmail.com>2012-03-07 12:54:27 -0800
commitd0429ea9b8849f99aa170cd09aef7776e2651dbf (patch)
tree6ced31803cdcd93464eae586f8591b4dddbf852a /keystone/common
parentfe6414c8c1f769e6cc87fc001b6c52c5fea0f160 (diff)
Make bind host configurable
* fixes bug 945868 Change-Id: Ib33dc9ad1878a9215c1a1ab10814fa7d0905cbdb
Diffstat (limited to 'keystone/common')
-rw-r--r--keystone/common/wsgi.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/keystone/common/wsgi.py b/keystone/common/wsgi.py
index 6279d4cc..f8a7e2f1 100644
--- a/keystone/common/wsgi.py
+++ b/keystone/common/wsgi.py
@@ -51,20 +51,21 @@ class WritableLogger(object):
class Server(object):
"""Server class to manage multiple WSGI sockets and applications."""
- def __init__(self, application, port, threads=1000):
+ def __init__(self, application, host=None, port=None, threads=1000):
self.application = application
- self.port = port
+ self.host = host or '0.0.0.0'
+ self.port = port or 0
self.pool = eventlet.GreenPool(threads)
self.socket_info = {}
self.greenthread = None
- def start(self, host='0.0.0.0', key=None, backlog=128):
+ def start(self, key=None, backlog=128):
"""Run a WSGI server with the given application."""
logging.debug('Starting %(arg0)s on %(host)s:%(port)s' %
{'arg0': sys.argv[0],
- 'host': host,
+ 'host': self.host,
'port': self.port})
- socket = eventlet.listen((host, self.port), backlog=backlog)
+ socket = eventlet.listen((self.host, self.port), backlog=backlog)
self.greenthread = self.pool.spawn(self._run, self.application, socket)
if key:
self.socket_info[key] = socket.getsockname()