jupyterhub-idle-culler
provides a JupyterHub service to cull and
shut down idle notebook servers and users on a JupyterHub deployment.
In jupyterhub_config.py
, add the following dictionary for the idle-culler
Service to the c.JupyterHub.services list:
c.JupyterHub.services = [
{
'name': 'idle-culler',
'admin': True,
'command': [
sys.executable,
'-m', 'jupyterhub_idle_culler',
'--timeout=3600'
],
}
]
where:
'admin': True
indicates that the Service requires admin permissions so it can shut down arbitrary user notebooks, and'command'
indicates that the Service will be managed by the Hub.
jupyterhub-idle-culler
can also be run as a standalone script. It can
access the hub's api with a service token. The service token must have
admin privileges.
Generate an API token and store it in a JUPYTERHUB_API_TOKEN
environment
variable. Then start jupyterhub-idle-culler
manually
export JUPYTERHUB_API_TOKEN=$(jupyterhub token)
python3 -m jupyterhub-idle-culler[--timeout=900] [--url=http://localhost:8081/hub/api]