-
Notifications
You must be signed in to change notification settings - Fork 1
Configuring SudoSpawner To Start Sandstone Servers
It is possible to configure ProfileSpawner and SudoSpawner to start Sandstone and Notebook servers behind the same JupyterHub deployment running with reduced privileges. For instructions on deploying Jupyterhub as a non-root user, see this article on using sudo to run JupyterHub without root privileges.
Start by installing the sandstone-jupyterhub-login
in your Sandstone HPC python environment.
Install wrapspawner.ProfilesSpawner to your JupyterHub python environment if you wish to spawn both Sandstone and Notebook servers:
pip install wrapspawner
Next install SudoSpawner into your JupyterHub python environment. This approach has only been verified on sudospawner==0.5.1
so you must be specific when installing the module.
pip install sudospawner==0.5.1
SudoSpawner supports a custom singleuser launch command for starting user processes via the mediator. This custom launch command must
- Reside in the same directory as the
sudospawner
script - Be named
sudospawner-singleuser
We can take advantage of this to launch the sandstone-jupyterhub
script via SudoSpawner (without interrupting normal SudoSpawner execution for Jupyter Notebooks) by making a copy of the sudospawner
script and linking the sandstone-jupyterhub
script adjacent to the copied script:
export SUDOSTONE_SCRIPTS=<path_to_your_new_executables_directory>
mkdir $SUDOSTONE_SCRIPTS
cd $SUDOSTONE_SCRIPTS
cp <path_to_jupyterhub_venv>/bin/sudospawner .
ln -s <path_to_sandstone_venv>/bin/sandstone-jupyterhub sudospawner-singleuser
Don't forget to add a sudoers rule for the copied sudospawner
script, as well as the original.
Note: If you do not wish to spawn both Sandstone and Notebook servers behind JupyterHub, you can skip making an alternative executables directory and instead just symlink the sandstone-jupyterhub
script in your virtualenv bin/
directory.
Modify your JupyterHub config as follows:
c.JupyterHub.spawner_class = 'wrapspawner.ProfilesSpawner'
c.ProfilesSpawner.profiles = [
('Jupyter Notebook', 'local', 'sudospawner.SudoSpawner', {}),
('Sandstone HPC', 'sandstone','sudospawner.SudoSpawner', {
'sudospawner_path': '<abspath_to_new_executables_dir>/sudospawner',
'environment': {'SANDSTONE_SETTINGS':'<abspath_to>/sandstone_settings.py'}
}),
]
c.SudoSpawner.debug_mediator = True
c.JupyterHub.log_level = 10