Files
the-littlest-jupyterhub/tljh/jupyterhub_config.py

47 lines
1.5 KiB
Python
Raw Normal View History

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