Skip to content

Configuring SudoSpawner To Start Sandstone Servers

Zebula Sampedro edited this page Dec 21, 2017 · 4 revisions

Overview

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.

Install sandstone-jupyterhub-login

Start by installing the sandstone-jupyterhub-login in your Sandstone HPC python environment.

Install ProfilesSpawner

Install wrapspawner.ProfilesSpawner to your JupyterHub python environment if you wish to spawn both Sandstone and Notebook servers:

pip install wrapspawner

Install SudoSpawner

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

Linking the sandstone-jupyterhub executable

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.

Configure JupyterHub

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