2018-06-15 16:54:40 -07:00
|
|
|
"""
|
|
|
|
|
JupyterHub config for the littlest jupyterhub.
|
|
|
|
|
"""
|
2019-02-11 13:27:08 +01:00
|
|
|
|
|
|
|
|
import os
|
2023-05-15 08:51:35 +00:00
|
|
|
from glob import glob
|
|
|
|
|
|
2020-11-16 10:44:49 +01:00
|
|
|
from tljh import configurer
|
2023-05-15 08:51:35 +00:00
|
|
|
from tljh.config import CONFIG_DIR, INSTALL_PREFIX, USER_ENV_PREFIX
|
2020-11-16 10:44:49 +01:00
|
|
|
from tljh.user_creating_spawner import UserCreatingSpawner
|
2023-05-15 08:51:35 +00:00
|
|
|
from tljh.utils import get_plugin_manager
|
2018-07-12 13:33:24 -07:00
|
|
|
|
2023-05-15 10:53:53 +02:00
|
|
|
c = get_config() # noqa
|
2018-09-12 16:46:59 -07:00
|
|
|
c.JupyterHub.spawner_class = UserCreatingSpawner
|
2018-06-15 16:17:07 -07:00
|
|
|
|
2018-08-29 16:46:04 +02:00
|
|
|
# leave users running when the Hub restarts
|
|
|
|
|
c.JupyterHub.cleanup_servers = False
|
|
|
|
|
|
2018-06-27 17:38:42 -07:00
|
|
|
# Use a high port so users can try this on machines with a JupyterHub already present
|
|
|
|
|
c.JupyterHub.hub_port = 15001
|
|
|
|
|
|
2023-05-15 10:53:53 +02:00
|
|
|
c.TraefikProxy.should_start = False
|
2019-02-11 09:24:16 +02:00
|
|
|
|
2021-11-03 23:55:34 +01:00
|
|
|
dynamic_conf_file_path = os.path.join(INSTALL_PREFIX, "state", "rules", "rules.toml")
|
2023-05-15 10:53:53 +02:00
|
|
|
c.TraefikFileProviderProxy.dynamic_config_file = dynamic_conf_file_path
|
|
|
|
|
c.JupyterHub.proxy_class = "traefik_file"
|
2018-06-27 17:38:42 -07:00
|
|
|
|
2021-11-03 23:55:34 +01:00
|
|
|
c.SystemdSpawner.extra_paths = [os.path.join(USER_ENV_PREFIX, "bin")]
|
|
|
|
|
c.SystemdSpawner.default_shell = "/bin/bash"
|
2018-06-29 01:24:30 -07:00
|
|
|
# Drop the '-singleuser' suffix present in the default template
|
2021-11-03 23:55:34 +01:00
|
|
|
c.SystemdSpawner.unit_name_template = "jupyter-{USERNAME}"
|
2018-06-27 01:18:07 -07:00
|
|
|
|
2019-02-22 11:17:59 +01:00
|
|
|
tljh_config = configurer.load_config()
|
|
|
|
|
configurer.apply_config(tljh_config, c)
|
2018-07-30 22:35:55 -07:00
|
|
|
|
2019-05-31 23:35:08 -07:00
|
|
|
# Let TLJH hooks modify `c` if they want
|
2019-06-01 00:32:23 -07:00
|
|
|
|
|
|
|
|
# Call our custom configuration plugin
|
2019-10-28 08:48:52 +01:00
|
|
|
pm = get_plugin_manager()
|
2019-06-01 00:32:23 -07:00
|
|
|
pm.hook.tljh_custom_jupyterhub_config(c=c)
|
2019-05-31 23:35:08 -07:00
|
|
|
|
2018-07-30 22:35:55 -07:00
|
|
|
# Load arbitrary .py config files if they exist.
|
|
|
|
|
# This is our escape hatch
|
2021-11-03 23:55:34 +01:00
|
|
|
extra_configs = sorted(glob(os.path.join(CONFIG_DIR, "jupyterhub_config.d", "*.py")))
|
2018-07-30 22:35:55 -07:00
|
|
|
for ec in extra_configs:
|
|
|
|
|
load_subconfig(ec)
|