mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
consolidate paths in config.py
This commit is contained in:
@@ -11,6 +11,8 @@ tljh-config show firstlevel
|
|||||||
|
|
||||||
tljh-config show firstlevel.second_level
|
tljh-config show firstlevel.second_level
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML
|
||||||
@@ -18,6 +20,13 @@ from copy import deepcopy
|
|||||||
from tljh import systemd, traefik
|
from tljh import systemd, traefik
|
||||||
|
|
||||||
|
|
||||||
|
INSTALL_PREFIX = os.environ.get('TLJH_INSTALL_PREFIX', '/opt/tljh')
|
||||||
|
HUB_ENV_PREFIX = os.path.join(INSTALL_PREFIX, 'hub')
|
||||||
|
USER_ENV_PREFIX = os.path.join(INSTALL_PREFIX, 'user')
|
||||||
|
STATE_DIR = os.path.join(INSTALL_PREFIX, 'state')
|
||||||
|
CONFIG_FILE = os.path.join(INSTALL_PREFIX, 'config.yaml')
|
||||||
|
|
||||||
|
|
||||||
yaml = YAML(typ='rt')
|
yaml = YAML(typ='rt')
|
||||||
|
|
||||||
|
|
||||||
@@ -28,7 +37,7 @@ def set_item_in_config(config, property_path, value):
|
|||||||
config is not mutated.
|
config is not mutated.
|
||||||
|
|
||||||
property_path is a series of dot separated values. Any part of the path
|
property_path is a series of dot separated values. Any part of the path
|
||||||
that does not exist is created.
|
that does not exist is created.
|
||||||
"""
|
"""
|
||||||
path_components = property_path.split('.')
|
path_components = property_path.split('.')
|
||||||
|
|
||||||
@@ -156,8 +165,7 @@ def reload_component(component):
|
|||||||
# FIXME: Verify hub is back up?
|
# FIXME: Verify hub is back up?
|
||||||
print('Hub reload with new configuration complete')
|
print('Hub reload with new configuration complete')
|
||||||
elif component == 'proxy':
|
elif component == 'proxy':
|
||||||
# FIXME: How to set path here?
|
traefik.ensure_traefik_config(STATE_DIR)
|
||||||
traefik.ensure_traefik_config('/opt/tljh/hub/state')
|
|
||||||
systemd.restart_service('configurable-http-proxy')
|
systemd.restart_service('configurable-http-proxy')
|
||||||
systemd.restart_service('traefik')
|
systemd.restart_service('traefik')
|
||||||
print('Proxy reload with new configuration complete')
|
print('Proxy reload with new configuration complete')
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ FIXME: A strong feeling that JSON Schema should be involved somehow.
|
|||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
INSTALL_PREFIX = os.environ.get('TLJH_INSTALL_PREFIX', '/opt/tljh')
|
from tljh.config import CONFIG_FILE
|
||||||
CONFIG_FILE = os.path.join(INSTALL_PREFIX, 'config.yaml')
|
|
||||||
|
|
||||||
# Default configuration for tljh
|
# Default configuration for tljh
|
||||||
# User provided config is merged into this
|
# User provided config is merged into this
|
||||||
|
|||||||
@@ -11,11 +11,7 @@ from urllib.request import urlopen, URLError
|
|||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML
|
||||||
|
|
||||||
from tljh import conda, systemd, traefik, user, apt
|
from tljh import conda, systemd, traefik, user, apt
|
||||||
|
from tljh.config import INSTALL_PREFIX, HUB_ENV_PREFIX, USER_ENV_PREFIX, STATE_DIR
|
||||||
INSTALL_PREFIX = os.environ.get('TLJH_INSTALL_PREFIX', '/opt/tljh')
|
|
||||||
HUB_ENV_PREFIX = os.path.join(INSTALL_PREFIX, 'hub')
|
|
||||||
USER_ENV_PREFIX = os.path.join(INSTALL_PREFIX, 'user')
|
|
||||||
STATE_DIR = os.path.join(INSTALL_PREFIX, 'state')
|
|
||||||
|
|
||||||
HERE = os.path.abspath(os.path.dirname(__file__))
|
HERE = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
"""
|
"""
|
||||||
JupyterHub config for the littlest jupyterhub.
|
JupyterHub config for the littlest jupyterhub.
|
||||||
"""
|
"""
|
||||||
|
import copy
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
|
||||||
from systemdspawner import SystemdSpawner
|
from systemdspawner import SystemdSpawner
|
||||||
from tljh import user, configurer
|
from tljh import user, configurer
|
||||||
import yaml
|
from tljh.config import INSTALL_PREFIX, USER_ENV_PREFIX
|
||||||
import copy
|
|
||||||
|
|
||||||
INSTALL_PREFIX = os.environ.get('TLJH_INSTALL_PREFIX')
|
|
||||||
USER_ENV_PREFIX = os.path.join(INSTALL_PREFIX, 'user')
|
|
||||||
|
|
||||||
|
|
||||||
class CustomSpawner(SystemdSpawner):
|
class CustomSpawner(SystemdSpawner):
|
||||||
|
|||||||
Reference in New Issue
Block a user