Merge pull request #88 from yuvipanda/reload-traefik

Fix traefik config reload
This commit is contained in:
Min RK
2018-07-31 12:39:55 +02:00
committed by GitHub
4 changed files with 20 additions and 14 deletions

View File

@@ -11,11 +11,19 @@ tljh-config show firstlevel
tljh-config show firstlevel.second_level
"""
import os
import sys
import argparse
from ruamel.yaml import YAML
from copy import deepcopy
from tljh import systemd
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')
@@ -28,7 +36,7 @@ def set_item_in_config(config, property_path, value):
config is not mutated.
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('.')
@@ -151,11 +159,14 @@ def reload_component(component):
component can be 'hub' or 'proxy'.
"""
# import here to avoid circular imports
from tljh import systemd, traefik
if component == 'hub':
systemd.restart_service('jupyterhub')
# FIXME: Verify hub is back up?
print('Hub reload with new configuration complete')
elif component == 'proxy':
traefik.ensure_traefik_config(STATE_DIR)
systemd.restart_service('configurable-http-proxy')
systemd.restart_service('traefik')
print('Proxy reload with new configuration complete')

View File

@@ -11,8 +11,7 @@ FIXME: A strong feeling that JSON Schema should be involved somehow.
import os
import yaml
INSTALL_PREFIX = os.environ.get('TLJH_INSTALL_PREFIX', '/opt/tljh')
CONFIG_FILE = os.path.join(INSTALL_PREFIX, 'config.yaml')
from tljh.config import CONFIG_FILE
# Default configuration for tljh
# User provided config is merged into this

View File

@@ -11,11 +11,7 @@ from urllib.request import urlopen, URLError
from ruamel.yaml import YAML
from tljh import conda, systemd, traefik, user, apt
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')
from tljh.config import INSTALL_PREFIX, HUB_ENV_PREFIX, USER_ENV_PREFIX, STATE_DIR
HERE = os.path.abspath(os.path.dirname(__file__))

View File

@@ -1,14 +1,14 @@
"""
JupyterHub config for the littlest jupyterhub.
"""
import copy
import os
import yaml
from systemdspawner import SystemdSpawner
from tljh import user, configurer
import yaml
import copy
INSTALL_PREFIX = os.environ.get('TLJH_INSTALL_PREFIX')
USER_ENV_PREFIX = os.path.join(INSTALL_PREFIX, 'user')
from tljh.config import INSTALL_PREFIX, USER_ENV_PREFIX
class CustomSpawner(SystemdSpawner):