Expose webapp listen_address and port
Move the hardcoded settings into the zuul.conf file to allow a user to
better customize them.
Change-Id: I9c817efc615ac3e8f8a7f4680dad14ef6cf3cc3b
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
diff --git a/doc/source/zuul.rst b/doc/source/zuul.rst
index ad8ec2e..a806c58 100644
--- a/doc/source/zuul.rst
+++ b/doc/source/zuul.rst
@@ -64,6 +64,17 @@
Path to log config file for internal Gearman server.
``log_config=/etc/zuul/gearman-logging.yaml``
+webapp
+""""""
+
+**listen_address**
+ IP address or domain name on which to listen (default: 0.0.0.0).
+ ``listen_address=127.0.0.1``
+
+**port**
+ Port on which the webapp is listening (default: 8001).
+ ``port=8008``
+
zuul
""""
diff --git a/etc/zuul.conf-sample b/etc/zuul.conf-sample
index 21c1317..d7b8eae 100644
--- a/etc/zuul.conf-sample
+++ b/etc/zuul.conf-sample
@@ -26,6 +26,10 @@
region_name=EXP
logserver_prefix=http://logs.example.org/server.app/
+[webapp]
+listen_address=0.0.0.0
+port=8001
+
[connection gerrit]
driver=gerrit
server=review.example.com
diff --git a/tests/base.py b/tests/base.py
index f3bfa4e..c866ddc 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -962,7 +962,8 @@
self.sched.setLauncher(self.launcher)
self.sched.setMerger(self.merge_client)
- self.webapp = zuul.webapp.WebApp(self.sched, port=0)
+ self.webapp = zuul.webapp.WebApp(
+ self.sched, port=0, listen_address='127.0.0.1')
self.rpc = zuul.rpclistener.RPCListener(self.config, self.sched)
self.sched.start()
diff --git a/zuul/cmd/server.py b/zuul/cmd/server.py
index 2aca4f2..550fad9 100755
--- a/zuul/cmd/server.py
+++ b/zuul/cmd/server.py
@@ -174,7 +174,20 @@
cache_expiry = self.config.getint('zuul', 'status_expiry')
else:
cache_expiry = 1
- webapp = zuul.webapp.WebApp(self.sched, cache_expiry=cache_expiry)
+
+ if self.config.has_option('webapp', 'listen_address'):
+ listen_address = self.config.get('webapp', 'listen_address')
+ else:
+ listen_address = '0.0.0.0'
+
+ if self.config.has_option('webapp', 'port'):
+ port = self.config.getint('webapp', 'port')
+ else:
+ port = 8001
+
+ webapp = zuul.webapp.WebApp(
+ self.sched, port=port, cache_expiry=cache_expiry,
+ listen_address=listen_address)
rpc = zuul.rpclistener.RPCListener(self.config, self.sched)
self.configure_connections()
diff --git a/zuul/webapp.py b/zuul/webapp.py
index 44c333b..c1c848b 100644
--- a/zuul/webapp.py
+++ b/zuul/webapp.py
@@ -43,16 +43,19 @@
class WebApp(threading.Thread):
log = logging.getLogger("zuul.WebApp")
- def __init__(self, scheduler, port=8001, cache_expiry=1):
+ def __init__(self, scheduler, port=8001, cache_expiry=1,
+ listen_address='0.0.0.0'):
threading.Thread.__init__(self)
self.scheduler = scheduler
+ self.listen_address = listen_address
self.port = port
self.cache_expiry = cache_expiry
self.cache_time = 0
self.cache = None
self.daemon = True
- self.server = httpserver.serve(dec.wsgify(self.app), host='0.0.0.0',
- port=self.port, start_loop=False)
+ self.server = httpserver.serve(
+ dec.wsgify(self.app), host=self.listen_address, port=self.port,
+ start_loop=False)
def run(self):
self.server.serve_forever()