diff --git a/doc/source/zuul.rst b/doc/source/zuul.rst index 27e7f4cc5a..2285ecbb66 100644 --- a/doc/source/zuul.rst +++ b/doc/source/zuul.rst @@ -75,6 +75,17 @@ than connecting to an external one. 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 21c1317d6d..d7b8eaeb55 100644 --- a/etc/zuul.conf-sample +++ b/etc/zuul.conf-sample @@ -26,6 +26,10 @@ default_container=logs 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 2d7f91866b..38d2817ac7 100755 --- a/tests/base.py +++ b/tests/base.py @@ -988,7 +988,8 @@ class ZuulTestCase(BaseTestCase): 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 9aa9c953fa..0b7538d7a4 100755 --- a/zuul/cmd/server.py +++ b/zuul/cmd/server.py @@ -173,7 +173,20 @@ class Server(zuul.cmd.ZuulApp): 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 44c333bf95..c1c848b211 100644 --- a/zuul/webapp.py +++ b/zuul/webapp.py @@ -43,16 +43,19 @@ array of changes, they will not include the queue structure. 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()