diff --git a/bootstrap/bootstrap.py b/bootstrap/bootstrap.py index 12cb3d4..d6efcdf 100644 --- a/bootstrap/bootstrap.py +++ b/bootstrap/bootstrap.py @@ -115,23 +115,23 @@ def serve_forever(server): pass def main(): - # Serve the loading page until TLJH builds - index_url="https://raw.githubusercontent.com/GeorgianaElena/the-littlest-jupyterhub/in-progress-page/bootstrap/index.html" - favicon_url="https://raw.githubusercontent.com/jupyterhub/jupyterhub/master/share/jupyterhub/static/favicon.ico" - urllib.request.urlretrieve(index_url, "index.html") - urllib.request.urlretrieve(favicon_url, "favicon.ico") + if "--temporary-page" in sys.argv: + # Serve the loading page until TLJH builds + index_url="https://raw.githubusercontent.com/GeorgianaElena/the-littlest-jupyterhub/in-progress-page/bootstrap/index.html" + favicon_url="https://raw.githubusercontent.com/jupyterhub/jupyterhub/master/share/jupyterhub/static/favicon.ico" + urllib.request.urlretrieve(index_url, "index.html") + urllib.request.urlretrieve(favicon_url, "favicon.ico") - - # If the bootstrap is run to upgrade TLJH, then this will raise an "Address already in use" error - try: - loading_page_server = HTTPServer(("", 80), LoaderPageRequestHandler) - p = multiprocessing.Process(target=serve_forever, args=(loading_page_server,)) - p.start() - with open('/loading.pid', 'w+') as f: - f.write(str(p.pid)) - except OSError: - # Only serve the loading page when installing TLJH - pass + # If the bootstrap is run to upgrade TLJH, then this will raise an "Address already in use" error + try: + loading_page_server = HTTPServer(("", 80), LoaderPageRequestHandler) + p = multiprocessing.Process(target=serve_forever, args=(loading_page_server,)) + p.start() + with open('/loading.pid', 'w+') as f: + f.write(str(p.pid)) + except OSError: + # Only serve the loading page when installing TLJH + pass validate_host() install_prefix = os.environ.get('TLJH_INSTALL_PREFIX', '/opt/tljh') diff --git a/tljh/installer.py b/tljh/installer.py index 9c74c31..fd00ef7 100644 --- a/tljh/installer.py +++ b/tljh/installer.py @@ -486,6 +486,12 @@ def main(): nargs='*', help='Plugin pip-specs to install' ) + argparser.add_argument( + '--temporary-page', + action='store_true', + default=False, + help='Serve a temporary page while TLJH is building' + ) args = argparser.parse_args() @@ -502,16 +508,18 @@ def main(): ensure_jupyterlab_extensions() # Stop the http server with the loading page before traefik starts - try: - with open(pidfile, "r") as f: - pid = f.read() - os.kill(int(pid), signal.SIGINT) - # Remove the pid file and the temporary html page - os.remove('/loading.pid') - os.remove('/index.html') - os.remove('/favicon.ico') - except: - pass + if args.temporary_page: + pidfile = "/loading.pid" + try: + with open(pidfile, "r") as f: + pid = f.read() + os.kill(int(pid), signal.SIGINT) + # Remove the pid file and the temporary html page + os.remove(pidfile) + os.remove('/index.html') + os.remove('/favicon.ico') + except Exception as e: + pass ensure_jupyterhub_service(HUB_ENV_PREFIX) ensure_jupyterhub_running()