mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Ensure dynamic config dir exists
This commit is contained in:
@@ -92,6 +92,7 @@ def ensure_traefik_config(state_dir):
|
|||||||
"""Render the traefik.toml config file"""
|
"""Render the traefik.toml config file"""
|
||||||
traefik_std_config_file = os.path.join(state_dir, "traefik.toml")
|
traefik_std_config_file = os.path.join(state_dir, "traefik.toml")
|
||||||
traefik_extra_config_dir = os.path.join(CONFIG_DIR, "traefik_config.d")
|
traefik_extra_config_dir = os.path.join(CONFIG_DIR, "traefik_config.d")
|
||||||
|
traefik_dynamic_config_dir = os.path.join(state_dir, "rules")
|
||||||
|
|
||||||
config = load_config()
|
config = load_config()
|
||||||
config['traefik_api']['basic_auth'] = compute_basic_auth(
|
config['traefik_api']['basic_auth'] = compute_basic_auth(
|
||||||
@@ -116,9 +117,12 @@ def ensure_traefik_config(state_dir):
|
|||||||
):
|
):
|
||||||
raise ValueError("Both email and domains must be set for letsencrypt")
|
raise ValueError("Both email and domains must be set for letsencrypt")
|
||||||
|
|
||||||
# Ensure extra config dir exists and is private
|
# Ensure traefik extra static config dir exists and is private
|
||||||
os.makedirs(traefik_extra_config_dir, mode=0o700, exist_ok=True)
|
os.makedirs(traefik_extra_config_dir, mode=0o700, exist_ok=True)
|
||||||
|
|
||||||
|
# Ensure traefik dynamic config dir exists and is private
|
||||||
|
os.makedirs(traefik_dynamic_config_dir, mode=0o700, exist_ok=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Load standard config file merge it with the extra config files into a dict
|
# Load standard config file merge it with the extra config files into a dict
|
||||||
extra_config = load_extra_config(traefik_extra_config_dir)
|
extra_config = load_extra_config(traefik_extra_config_dir)
|
||||||
@@ -131,7 +135,7 @@ def ensure_traefik_config(state_dir):
|
|||||||
os.fchmod(f.fileno(), 0o600)
|
os.fchmod(f.fileno(), 0o600)
|
||||||
toml.dump(new_toml, f)
|
toml.dump(new_toml, f)
|
||||||
|
|
||||||
with open(os.path.join(state_dir, 'rules', "rules.toml"), "w") as f:
|
with open(os.path.join(traefik_dynamic_config_dir, "rules.toml"), "w") as f:
|
||||||
os.fchmod(f.fileno(), 0o600)
|
os.fchmod(f.fileno(), 0o600)
|
||||||
|
|
||||||
# ensure acme.json exists and is private
|
# ensure acme.json exists and is private
|
||||||
|
|||||||
Reference in New Issue
Block a user