Replace chp with traefik-proxy

This commit is contained in:
GeorgianaElena
2019-01-22 16:24:38 +02:00
parent 5d533735aa
commit eee29a0957
14 changed files with 119 additions and 97 deletions

View File

@@ -70,3 +70,48 @@ def enable_service(name):
'enable',
name
], check=True)
def check_service_active(name):
"""
Check if a service is currently active (running)
"""
try:
subprocess.run([
'systemctl',
'is-active',
name
], check=True)
return True
except subprocess.CalledProcessError:
return False
def check_hub_ready():
"""
Check if the hub is ready
"""
try:
last_restart = subprocess.check_output([
'systemctl',
'show',
'jupyterhub',
'-p',
'ActiveEnterTimestamp'
]).decode().strip()
last_restart = " ".join(last_restart.split(" ")[-3:-1])
out = subprocess.check_output([
'journalctl',
'-u',
'jupyterhub',
'--since',
last_restart
])
if "JupyterHub is now running at" in out.decode():
return True
except subprocess.CalledProcessError:
return False