Merge "Expose webapp listen_address and port"

This commit is contained in:
Jenkins 2016-07-12 23:31:02 +00:00 committed by Gerrit Code Review
commit c19d3d9eff
5 changed files with 37 additions and 5 deletions

View File

@ -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
""""

View File

@ -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

View File

@ -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()

View File

@ -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()

View File

@ -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()