Jupyter server source script on launch

Definitely possible. JupyterHub’s Spawner.cmd only requires that it eventually launches jupyterhub-singleuser (or one of a few equivalents like jupyter-labhub).

The standard way to do this, and one that I think gives a nice experience, is to create a launcher script like:

#!/bin/bash -l

# set any additional environment variables / do other startup

# finally, 'become' jupyterhub-singleuser
exec jupyterhub-singleuser "$@"

The bash -l starts a login shell, so it should be fully configured with profile, etc.

Then you set c.Spawner.cmd = "/path/to/that/script.sh" in your config, instead of the default jupyterhub-singleuser.

4 Likes