Skip to content

Commit

Permalink
Merge branch 'main' into gateway-client
Browse files Browse the repository at this point in the history
  • Loading branch information
Zsailer authored May 6, 2022
2 parents 9481a02 + 05834ea commit f87a2f9
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,29 @@ def shutdown_server(server_info, timeout=5, log=None):
url = server_info["url"]
pid = server_info["pid"]

if log:
log.debug("POST request to %sapi/shutdown", url)
try:
shutdown_url = urljoin(url, "api/shutdown")
if log:
log.debug("POST request to %s", shutdown_url)
fetch(
shutdown_url,
method="POST",
body=b"",
headers={"Authorization": "token " + server_info["token"]},
)
except Exception as ex:
if not str(ex) == "Unknown URL scheme.":
raise ex
if log:
log.debug("Was not a HTTP scheme. Treating as socket instead.")
log.debug("POST request to %s", url)
fetch(
url,
method="POST",
body=b"",
headers={"Authorization": "token " + server_info["token"]},
)

fetch(url, method="POST", body=b"", headers={"Authorization": "token " + server_info["token"]})
# Poll to see if it shut down.
for _ in range(timeout * 10):
if not check_pid(pid):
Expand Down

0 comments on commit f87a2f9

Please sign in to comment.