Pass the pid to the installer as a cmd arg

This commit is contained in:
GeorgianaElena
2020-08-11 16:01:44 +03:00
parent fcb5257901
commit d1bee23a7d
2 changed files with 6 additions and 11 deletions

View File

@@ -102,7 +102,7 @@ class LoaderPageRequestHandler(SimpleHTTPRequestHandler):
elif self.path == "/index.html" or self.path == "/favicon.ico":
return SimpleHTTPRequestHandler.do_GET(self)
elif self.path == "/":
self.send_response(301)
self.send_response(302)
self.send_header('Location','/index.html')
self.end_headers()
else:
@@ -115,7 +115,8 @@ def serve_forever(server):
pass
def main():
if "--temporary-page" in sys.argv:
temp_page_flag = "--temporary-page"
if temp_page_flag 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"
@@ -127,8 +128,8 @@ def main():
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))
# Put the pid after the temp page flag to be passed to the istaller
sys.argv.insert(sys.argv.index(temp_page_flag)+1, str(p.pid))
except OSError:
# Only serve the loading page when installing TLJH
pass

View File

@@ -488,8 +488,6 @@ def main():
)
argparser.add_argument(
'--temporary-page',
action='store_true',
default=False,
help='Serve a temporary page while TLJH is building'
)
@@ -509,13 +507,9 @@ def main():
# Stop the http server with the loading page before traefik starts
if args.temporary_page:
pidfile = "/loading.pid"
try:
with open(pidfile, "r") as f:
pid = f.read()
os.kill(int(pid), signal.SIGINT)
os.kill(int(args.temporary_page), 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: