From 0f93571ca5060d6863cb564e916d69beb7370040 Mon Sep 17 00:00:00 2001 From: Min RK Date: Thu, 26 Sep 2019 14:58:26 +0200 Subject: [PATCH] verify proxy is accessible before listening on the hub lighter weight than check_routes --- jupyterhub/app.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/jupyterhub/app.py b/jupyterhub/app.py index 9634773b..54422dd0 100644 --- a/jupyterhub/app.py +++ b/jupyterhub/app.py @@ -2452,6 +2452,20 @@ class JupyterHub(Application): loop.stop() return + # start the proxy + if self.proxy.should_start: + try: + await self.proxy.start() + except Exception as e: + self.log.critical("Failed to start proxy", exc_info=True) + self.exit(1) + else: + self.log.info("Not starting proxy") + + # verify that we can talk to the proxy before listening. + # avoids delayed failure if we can't talk to the proxy + await self.proxy.get_all_routes() + ssl_context = make_ssl_context( self.internal_ssl_key, self.internal_ssl_cert, @@ -2489,16 +2503,6 @@ class JupyterHub(Application): self.log.error("Failed to bind hub to %s", self.hub.bind_url) raise - # start the proxy - if self.proxy.should_start: - try: - await self.proxy.start() - except Exception as e: - self.log.critical("Failed to start proxy", exc_info=True) - self.exit(1) - else: - self.log.info("Not starting proxy") - # start the service(s) for service_name, service in self._service_map.items(): msg = (