mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 22:13:00 +00:00
add external-service shared notebook example
This commit is contained in:
@@ -6,5 +6,20 @@ one as a 'managed' service, and one as an external service with supervisor.
|
||||
A single-user notebook server is run as a service,
|
||||
and uses groups to authenticate a collection of users with the Hub.
|
||||
|
||||
In these examples, a JupyterHub group `'shared'` is created,
|
||||
and a notebook server is spawned at `/services/shared-notebook`.
|
||||
Any user in the `'shared'` group will be able to access the notebook server at `/services/shared-notebook/`.
|
||||
|
||||
In both examples, you will want to select the name of the group,
|
||||
and the name of the shared-notebook service.
|
||||
|
||||
In the external example, some extra steps are required to set up supervisor:
|
||||
|
||||
1. select a system user to run the service. This is a user on the system, and does not need to be a Hub user. Add this to the user field in `shared-notebook.conf`, replacing `someuser`.
|
||||
2. generate a secret token for authentication, and replace the `super-secret` fields in `shared-notebook-service` and `jupyterhub_config.py`
|
||||
3. install `shared-notebook-service` somewhere on your system, and update `/path/to/shared-notebook-service` to the absolute path of this destination
|
||||
3. copy `shared-notebook.conf` to `/etc/supervisor/conf.d/`
|
||||
4. `supervisorctl reload`
|
||||
|
||||
These examples require jupyterhub >= 0.7.2.
|
||||
|
||||
|
24
examples/service-notebook/external/jupyterhub_config.py
vendored
Normal file
24
examples/service-notebook/external/jupyterhub_config.py
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# our user list
|
||||
c.Authenticator.whitelist = [
|
||||
'minrk',
|
||||
'ellisonbg',
|
||||
'willingc',
|
||||
]
|
||||
|
||||
# ellisonbg and willingc have access to a shared server:
|
||||
|
||||
c.JupyterHub.load_groups = {
|
||||
'shared': [
|
||||
'ellisonbg',
|
||||
'willingc',
|
||||
]
|
||||
}
|
||||
|
||||
# start the notebook server as a service
|
||||
c.JupyterHub.services = [
|
||||
{
|
||||
'name': 'shared-notebook',
|
||||
'url': 'http://127.0.0.1:9999',
|
||||
'api_token': 'super-secret',
|
||||
}
|
||||
]
|
12
examples/service-notebook/external/shared-notebook-service
vendored
Executable file
12
examples/service-notebook/external/shared-notebook-service
vendored
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash -l
|
||||
set -e
|
||||
|
||||
export JUPYTERHUB_API_TOKEN=super-secret
|
||||
|
||||
jupyterhub-singleuser \
|
||||
--cookie-name=jupyterhub-services \
|
||||
--port=9999 \
|
||||
--group='shared' \
|
||||
--base-url=/services/shared-notebook \
|
||||
--hub-prefix=/hub/ \
|
||||
--hub-api-url=http://127.0.0.1:8081/hub/api/
|
14
examples/service-notebook/external/shared-notebook.conf
vendored
Normal file
14
examples/service-notebook/external/shared-notebook.conf
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
[program:jupyterhub-shared-notebook]
|
||||
user=someuser
|
||||
command=bash -l /path/to/shared-notebook-service
|
||||
directory=/home/someuser
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startretries=1
|
||||
exitcodes=0,2
|
||||
stopsignal=TERM
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/var/log/jupyterhub-service-shared-notebook.log
|
||||
stdout_logfile_maxbytes=1MB
|
||||
stdout_logfile_backups=10
|
||||
stdout_capture_maxbytes=1MB
|
Reference in New Issue
Block a user