Added more comments

This commit is contained in:
GeorgianaElena
2020-08-17 19:04:25 +03:00
parent cef898fd31
commit 1ce172ae3e
2 changed files with 17 additions and 8 deletions

View File

@@ -177,9 +177,13 @@ def validate_host():
class LoaderPageRequestHandler(SimpleHTTPRequestHandler): class LoaderPageRequestHandler(SimpleHTTPRequestHandler):
def do_GET(self): def do_GET(self):
if self.path == "/logs": if self.path == "/logs":
with open("/opt/tljh/installer.log", "rb") as log_file: with open("/opt/tljh/installer.log", "r") as log_file:
content = log_file.read() logs = log_file.read()
self.wfile.write(content)
self.send_response(200)
self.send_header('Content-Type', 'text/plain; charset=utf-8')
self.end_headers()
self.wfile.write(logs.encode('utf-8'))
elif self.path == "/index.html": elif self.path == "/index.html":
self.path = "/var/run/index.html" self.path = "/var/run/index.html"
return SimpleHTTPRequestHandler.do_GET(self) return SimpleHTTPRequestHandler.do_GET(self)
@@ -203,8 +207,10 @@ def main():
flags = sys.argv[1:] flags = sys.argv[1:]
temp_page_flag = "--show-progress-page" temp_page_flag = "--show-progress-page"
# Check for flag in the argv list. This doesn't use argparse
# because it's the only argument that's meant for the boostrap script.
# All the other flags will be passed to and parsed by the installer.
if temp_page_flag in flags: if temp_page_flag in flags:
# Serve the loading page until TLJH builds
with open("/var/run/index.html", "w+") as f: with open("/var/run/index.html", "w+") as f:
f.write(html) f.write(html)
favicon_url="https://raw.githubusercontent.com/jupyterhub/jupyterhub/master/share/jupyterhub/static/favicon.ico" favicon_url="https://raw.githubusercontent.com/jupyterhub/jupyterhub/master/share/jupyterhub/static/favicon.ico"
@@ -214,9 +220,13 @@ def main():
try: try:
loading_page_server = HTTPServer(("", 80), LoaderPageRequestHandler) loading_page_server = HTTPServer(("", 80), LoaderPageRequestHandler)
p = multiprocessing.Process(target=serve_forever, args=(loading_page_server,)) p = multiprocessing.Process(target=serve_forever, args=(loading_page_server,))
# Serves the loading page until TLJH builds
p.start() p.start()
# Remove the flag from the args list, since it was only relevant to this script.
flags.remove("--show-progress-page")
# Pass the server's pid as a flag to the istaller # Pass the server's pid as a flag to the istaller
flags.remove(temp_page_flag)
pid_flag = "--progress-page-server-pid" pid_flag = "--progress-page-server-pid"
flags.extend([pid_flag, str(p.pid)]) flags.extend([pid_flag, str(p.pid)])
except OSError: except OSError:

View File

@@ -507,10 +507,9 @@ def main():
ensure_jupyterlab_extensions() ensure_jupyterlab_extensions()
# Stop the http server with the loading page before traefik starts # Stop the http server with the loading page before traefik starts
if args.temporary_page: if args.progress_page_server_pid:
try: try:
os.kill(int(args.temporary_page), signal.SIGINT) os.kill(args.progress_page_server_pid, signal.SIGINT)
# Remove the pid file and the temporary html page
except Exception as e: except Exception as e:
pass pass