mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-10 11:32:57 +00:00

* Get healthcheck URL from JSON file Obtain Jupyter server's full URL from /home/$NB_USER/.local/share/jupyter/runtime/*.json and use it for healthcheck. * Expand tests for healthcheck * Update pre-commit config * Remove workdir from tests * Wait for container start with 0.1s interval * Quote NB_USER variable on base-notebook/Dockerfile * Fix style and make test actually work * Ooops, GitHub didn't show last line * Fix mypy * Use bash with pipefail option for healthcheck * Create python script for healthcheck * Don't verify SSL certificate on healthcheck * Update healthcheck test - Add "user" parameter - Add tests when container should not be healthy * Fix typo * Update test_healthcheck.py --------- Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
19 lines
556 B
Python
19 lines
556 B
Python
import json
|
|
import os
|
|
|
|
import requests
|
|
|
|
# A number of operations below delibrately don't check for possible errors
|
|
# As this is a healthcheck, it should succeed or raise an exception on error
|
|
|
|
runtime_dir = "/home/" + os.environ["NB_USER"] + "/.local/share/jupyter/runtime/"
|
|
file_list = os.listdir(runtime_dir)
|
|
json_file = [s for s in file_list if s.endswith(".json")]
|
|
|
|
url = json.load(open(runtime_dir + json_file[0]))["url"]
|
|
url = url + "api"
|
|
|
|
r = requests.get(url, verify=False) # request without SSL verification
|
|
r.raise_for_status()
|
|
print(r.content)
|