mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Replace chp with traefik-proxy
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user