mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Pass the pid to the installer as a cmd arg
This commit is contained in:
@@ -102,7 +102,7 @@ class LoaderPageRequestHandler(SimpleHTTPRequestHandler):
|
|||||||
elif self.path == "/index.html" or self.path == "/favicon.ico":
|
elif self.path == "/index.html" or self.path == "/favicon.ico":
|
||||||
return SimpleHTTPRequestHandler.do_GET(self)
|
return SimpleHTTPRequestHandler.do_GET(self)
|
||||||
elif self.path == "/":
|
elif self.path == "/":
|
||||||
self.send_response(301)
|
self.send_response(302)
|
||||||
self.send_header('Location','/index.html')
|
self.send_header('Location','/index.html')
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
else:
|
else:
|
||||||
@@ -115,7 +115,8 @@ def serve_forever(server):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def main():
|
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
|
# Serve the loading page until TLJH builds
|
||||||
index_url="https://raw.githubusercontent.com/GeorgianaElena/the-littlest-jupyterhub/in-progress-page/bootstrap/index.html"
|
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"
|
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)
|
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,))
|
||||||
p.start()
|
p.start()
|
||||||
with open('/loading.pid', 'w+') as f:
|
# Put the pid after the temp page flag to be passed to the istaller
|
||||||
f.write(str(p.pid))
|
sys.argv.insert(sys.argv.index(temp_page_flag)+1, str(p.pid))
|
||||||
except OSError:
|
except OSError:
|
||||||
# Only serve the loading page when installing TLJH
|
# Only serve the loading page when installing TLJH
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -488,8 +488,6 @@ def main():
|
|||||||
)
|
)
|
||||||
argparser.add_argument(
|
argparser.add_argument(
|
||||||
'--temporary-page',
|
'--temporary-page',
|
||||||
action='store_true',
|
|
||||||
default=False,
|
|
||||||
help='Serve a temporary page while TLJH is building'
|
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
|
# Stop the http server with the loading page before traefik starts
|
||||||
if args.temporary_page:
|
if args.temporary_page:
|
||||||
pidfile = "/loading.pid"
|
|
||||||
try:
|
try:
|
||||||
with open(pidfile, "r") as f:
|
os.kill(int(args.temporary_page), signal.SIGINT)
|
||||||
pid = f.read()
|
|
||||||
os.kill(int(pid), signal.SIGINT)
|
|
||||||
# Remove the pid file and the temporary html page
|
# Remove the pid file and the temporary html page
|
||||||
os.remove(pidfile)
|
|
||||||
os.remove('/index.html')
|
os.remove('/index.html')
|
||||||
os.remove('/favicon.ico')
|
os.remove('/favicon.ico')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user