Services¶
Module: jupyterhub.services.service
¶
A service is a process that talks to JupyterHub.
- Types of services:
- Managed:
- managed by JupyterHub (always subprocess, no custom Spawners)
- always a long-running process
- managed services are restarted automatically if they exit unexpectedly
- Unmanaged:
- managed by external service (docker, systemd, etc.)
- do not need to be long-running processes, or processes at all
- URL: needs a route added to the proxy.
- Public route will always be /services/service-name
- url specified in config
- if port is 0, Hub will select a port
- API access:
- admin: tokens will have admin-access to the API
- not admin: tokens will only have non-admin access (not much they can do other than defer to Hub for auth)
An externally managed service running on a URL:
{
'name': 'my-service',
'url': 'https://host:8888',
'admin': True,
'api_token': 'super-secret',
}
A hub-managed service with no URL:
{
'name': 'cull-idle',
'command': ['python', '/path/to/cull-idle']
'admin': True,
}
Service
¶
-
class
jupyterhub.services.service.
Service
(**kwargs)¶ An object wrapping a service specification for Hub API consumers.
A service has inputs:
- name: str
- the name of the service
- admin: bool(false)
- whether the service should have administrative privileges
- url: str (None)
- The URL where the service is/should be. If specified, the service will be added to the proxy at /services/:name
If a service is to be managed by the Hub, it has a few extra options:
- command: (str/Popen list)
- Command for JupyterHub to spawn the service. Only use this if the service should be a subprocess. If command is not specified, it is assumed to be managed by a
- environment: dict
- Additional environment variables for the service.
- user: str
- The name of a system user to become. If unspecified, run as the same user as the Hub.
-
kind
¶ The name of the kind of service as a string
- ‘managed’ for managed services
- ‘external’ for external services
-
managed
¶ Am I managed by the Hub?