Hello,
We’ve deployed Jupyterhub on Kubernetes and we’re looking to implement 2 monitoring/administration features using python code (set in hub.extraConfig.customAuthConfig).
We have a pre_spawn_hook that launches a thread containing monitoring logic, and we’d like to, conditionally, perform one of these two actions:
1- Terminate the current user session, making them required to re-authenticate
2- Cull the current user server, making them required to re-start it
Kindly review this demo of the python extraConfig we’re aiming to use:
import threading
import time
def monitor_session(spawner):
while True:
# Reset the authentication, if a condition is satisfied
# Stop the server, if a condition is satisfied
time.sleep(100)
def demo_pre_spawn_hook(spawner):
monitor_session_thread = threading.Thread(target=monitor_session, args=[spawner])
monitor_session_thread.start()
c.Spawner.pre_spawn_hook = demo_pre_spawn_hook
Is it possible to implement this custom logout and server shutdown logic in this manner? If not, are there any alternatives?
Thank you!