mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-09 02:54:09 +00:00
@@ -54,7 +54,7 @@ If a service is also to be managed by the Hub, it has a few extra options:
|
|||||||
externally.
|
externally.
|
||||||
- If a command is specified for launching the Service, the Service will
|
- If a command is specified for launching the Service, the Service will
|
||||||
be started and managed by the Hub.
|
be started and managed by the Hub.
|
||||||
- `env: dict` - environment variables to add to the current env
|
- `environment: dict` - additional environment variables for the Service.
|
||||||
- `user: str` - the name of a system user to manage the Service. If
|
- `user: str` - the name of a system user to manage the Service. If
|
||||||
unspecified, run as the same user as the Hub.
|
unspecified, run as the same user as the Hub.
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ c.JupyterHub.services = [
|
|||||||
A Hub-Managed Service may also be configured with additional optional
|
A Hub-Managed Service may also be configured with additional optional
|
||||||
parameters, which describe the environment needed to start the Service process:
|
parameters, which describe the environment needed to start the Service process:
|
||||||
|
|
||||||
- `env: dict` - additional environment variables for the Service.
|
- `environment: dict` - additional environment variables for the Service.
|
||||||
- `user: str` - name of the user to run the server if different from the Hub.
|
- `user: str` - name of the user to run the server if different from the Hub.
|
||||||
Requires Hub to be root.
|
Requires Hub to be root.
|
||||||
- `cwd: path` directory in which to run the Service, if different from the
|
- `cwd: path` directory in which to run the Service, if different from the
|
||||||
|
@@ -146,18 +146,18 @@ class NewToken(Application):
|
|||||||
|
|
||||||
class UpgradeDB(Application):
|
class UpgradeDB(Application):
|
||||||
"""Upgrade the JupyterHub database schema."""
|
"""Upgrade the JupyterHub database schema."""
|
||||||
|
|
||||||
name = 'jupyterhub-upgrade-db'
|
name = 'jupyterhub-upgrade-db'
|
||||||
version = jupyterhub.__version__
|
version = jupyterhub.__version__
|
||||||
description = """Upgrade the JupyterHub database to the current schema.
|
description = """Upgrade the JupyterHub database to the current schema.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
jupyterhub upgrade-db
|
jupyterhub upgrade-db
|
||||||
"""
|
"""
|
||||||
aliases = common_aliases
|
aliases = common_aliases
|
||||||
classes = []
|
classes = []
|
||||||
|
|
||||||
def _backup_db_file(self, db_file):
|
def _backup_db_file(self, db_file):
|
||||||
"""Backup a database file"""
|
"""Backup a database file"""
|
||||||
if not os.path.exists(db_file):
|
if not os.path.exists(db_file):
|
||||||
@@ -171,7 +171,7 @@ class UpgradeDB(Application):
|
|||||||
backup_db_file = '{}.{}.{}'.format(db_file, timestamp, i)
|
backup_db_file = '{}.{}.{}'.format(db_file, timestamp, i)
|
||||||
if os.path.exists(backup_db_file):
|
if os.path.exists(backup_db_file):
|
||||||
self.exit("backup db file already exists: %s" % backup_db_file)
|
self.exit("backup db file already exists: %s" % backup_db_file)
|
||||||
|
|
||||||
self.log.info("Backing up %s => %s", db_file, backup_db_file)
|
self.log.info("Backing up %s => %s", db_file, backup_db_file)
|
||||||
shutil.copy(db_file, backup_db_file)
|
shutil.copy(db_file, backup_db_file)
|
||||||
|
|
||||||
@@ -222,12 +222,12 @@ class JupyterHub(Application):
|
|||||||
Authenticator,
|
Authenticator,
|
||||||
PAMAuthenticator,
|
PAMAuthenticator,
|
||||||
])
|
])
|
||||||
|
|
||||||
load_groups = Dict(List(Unicode()),
|
load_groups = Dict(List(Unicode()),
|
||||||
help="""Dict of 'group': ['usernames'] to load at startup.
|
help="""Dict of 'group': ['usernames'] to load at startup.
|
||||||
|
|
||||||
This strictly *adds* groups and users to groups.
|
This strictly *adds* groups and users to groups.
|
||||||
|
|
||||||
Loading one set of groups, then starting JupyterHub again with a different
|
Loading one set of groups, then starting JupyterHub again with a different
|
||||||
set will not remove users or groups from previous launches.
|
set will not remove users or groups from previous launches.
|
||||||
That must be done through the API.
|
That must be done through the API.
|
||||||
@@ -414,7 +414,7 @@ class JupyterHub(Application):
|
|||||||
|
|
||||||
api_tokens = Dict(Unicode(),
|
api_tokens = Dict(Unicode(),
|
||||||
help="""PENDING DEPRECATION: consider using service_tokens
|
help="""PENDING DEPRECATION: consider using service_tokens
|
||||||
|
|
||||||
Dict of token:username to be loaded into the database.
|
Dict of token:username to be loaded into the database.
|
||||||
|
|
||||||
Allows ahead-of-time generation of API tokens for use by externally managed services,
|
Allows ahead-of-time generation of API tokens for use by externally managed services,
|
||||||
@@ -437,14 +437,14 @@ class JupyterHub(Application):
|
|||||||
Allows ahead-of-time generation of API tokens for use by externally managed services.
|
Allows ahead-of-time generation of API tokens for use by externally managed services.
|
||||||
"""
|
"""
|
||||||
).tag(config=True)
|
).tag(config=True)
|
||||||
|
|
||||||
services = List(Dict(),
|
services = List(Dict(),
|
||||||
help="""List of service specification dictionaries.
|
help="""List of service specification dictionaries.
|
||||||
|
|
||||||
A service
|
A service
|
||||||
|
|
||||||
For instance::
|
For instance::
|
||||||
|
|
||||||
services = [
|
services = [
|
||||||
{
|
{
|
||||||
'name': 'cull_idle',
|
'name': 'cull_idle',
|
||||||
@@ -454,7 +454,7 @@ class JupyterHub(Application):
|
|||||||
'name': 'formgrader',
|
'name': 'formgrader',
|
||||||
'url': 'http://127.0.0.1:1234',
|
'url': 'http://127.0.0.1:1234',
|
||||||
'token': 'super-secret',
|
'token': 'super-secret',
|
||||||
'env':
|
'environment':
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
@@ -608,7 +608,7 @@ class JupyterHub(Application):
|
|||||||
Instance(logging.Handler),
|
Instance(logging.Handler),
|
||||||
help="Extra log handlers to set on JupyterHub logger",
|
help="Extra log handlers to set on JupyterHub logger",
|
||||||
).tag(config=True)
|
).tag(config=True)
|
||||||
|
|
||||||
statsd = Any(allow_none=False, help="The statsd client, if any. A mock will be used if we aren't using statsd")
|
statsd = Any(allow_none=False, help="The statsd client, if any. A mock will be used if we aren't using statsd")
|
||||||
@default('statsd')
|
@default('statsd')
|
||||||
def _statsd(self):
|
def _statsd(self):
|
||||||
@@ -919,7 +919,7 @@ class JupyterHub(Application):
|
|||||||
# The whitelist set and the users in the db are now the same.
|
# The whitelist set and the users in the db are now the same.
|
||||||
# From this point on, any user changes should be done simultaneously
|
# From this point on, any user changes should be done simultaneously
|
||||||
# to the whitelist set and user db, unless the whitelist is empty (all users allowed).
|
# to the whitelist set and user db, unless the whitelist is empty (all users allowed).
|
||||||
|
|
||||||
@gen.coroutine
|
@gen.coroutine
|
||||||
def init_groups(self):
|
def init_groups(self):
|
||||||
"""Load predefined groups into the database"""
|
"""Load predefined groups into the database"""
|
||||||
@@ -941,7 +941,7 @@ class JupyterHub(Application):
|
|||||||
db.add(user)
|
db.add(user)
|
||||||
group.users.append(user)
|
group.users.append(user)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
@gen.coroutine
|
@gen.coroutine
|
||||||
def _add_tokens(self, token_dict, kind):
|
def _add_tokens(self, token_dict, kind):
|
||||||
"""Add tokens for users or services to the database"""
|
"""Add tokens for users or services to the database"""
|
||||||
@@ -982,13 +982,13 @@ class JupyterHub(Application):
|
|||||||
else:
|
else:
|
||||||
self.log.debug("Not duplicating token %s", orm_token)
|
self.log.debug("Not duplicating token %s", orm_token)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
@gen.coroutine
|
@gen.coroutine
|
||||||
def init_api_tokens(self):
|
def init_api_tokens(self):
|
||||||
"""Load predefined API tokens (for services) into database"""
|
"""Load predefined API tokens (for services) into database"""
|
||||||
yield self._add_tokens(self.service_tokens, kind='service')
|
yield self._add_tokens(self.service_tokens, kind='service')
|
||||||
yield self._add_tokens(self.api_tokens, kind='user')
|
yield self._add_tokens(self.api_tokens, kind='user')
|
||||||
|
|
||||||
def init_services(self):
|
def init_services(self):
|
||||||
self._service_map.clear()
|
self._service_map.clear()
|
||||||
if self.domain:
|
if self.domain:
|
||||||
@@ -1458,7 +1458,7 @@ class JupyterHub(Application):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.critical("Failed to start proxy", exc_info=True)
|
self.log.critical("Failed to start proxy", exc_info=True)
|
||||||
self.exit(1)
|
self.exit(1)
|
||||||
|
|
||||||
for service_name, service in self._service_map.items():
|
for service_name, service in self._service_map.items():
|
||||||
if not service.managed:
|
if not service.managed:
|
||||||
continue
|
continue
|
||||||
|
@@ -70,12 +70,12 @@ class _MockUser(HasTraits):
|
|||||||
|
|
||||||
class _ServiceSpawner(LocalProcessSpawner):
|
class _ServiceSpawner(LocalProcessSpawner):
|
||||||
"""Subclass of LocalProcessSpawner
|
"""Subclass of LocalProcessSpawner
|
||||||
|
|
||||||
Removes notebook-specific-ness from LocalProcessSpawner.
|
Removes notebook-specific-ness from LocalProcessSpawner.
|
||||||
"""
|
"""
|
||||||
cwd = Unicode()
|
cwd = Unicode()
|
||||||
cmd = Command(minlen=0)
|
cmd = Command(minlen=0)
|
||||||
|
|
||||||
def make_preexec_fn(self, name):
|
def make_preexec_fn(self, name):
|
||||||
if not name or name == getuser():
|
if not name or name == getuser():
|
||||||
# no setuid if no name
|
# no setuid if no name
|
||||||
@@ -116,25 +116,25 @@ class Service(LoggingConfigurable):
|
|||||||
- url: str (None)
|
- url: str (None)
|
||||||
The URL where the service is/should be.
|
The URL where the service is/should be.
|
||||||
If specified, the service will be added to the proxy at /services/:name
|
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:
|
If a service is to be managed by the Hub, it has a few extra options:
|
||||||
|
|
||||||
- command: (str/Popen list)
|
- command: (str/Popen list)
|
||||||
Command for JupyterHub to spawn the service.
|
Command for JupyterHub to spawn the service.
|
||||||
Only use this if the service should be a subprocess.
|
Only use this if the service should be a subprocess.
|
||||||
If command is not specified, it is assumed to be managed
|
If command is not specified, it is assumed to be managed
|
||||||
by a
|
by a
|
||||||
- env: dict
|
- environment: dict
|
||||||
environment variables to add to the current env
|
Additional environment variables for the service.
|
||||||
- user: str
|
- user: str
|
||||||
The name of a system user to become.
|
The name of a system user to become.
|
||||||
If unspecified, run as the same user as the Hub.
|
If unspecified, run as the same user as the Hub.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# inputs:
|
# inputs:
|
||||||
name = Unicode(
|
name = Unicode(
|
||||||
help="""The name of the service.
|
help="""The name of the service.
|
||||||
|
|
||||||
If the service has an http endpoint, it
|
If the service has an http endpoint, it
|
||||||
"""
|
"""
|
||||||
).tag(input=True)
|
).tag(input=True)
|
||||||
@@ -143,14 +143,14 @@ class Service(LoggingConfigurable):
|
|||||||
).tag(input=True)
|
).tag(input=True)
|
||||||
url = Unicode(
|
url = Unicode(
|
||||||
help="""URL of the service.
|
help="""URL of the service.
|
||||||
|
|
||||||
Only specify if the service runs an HTTP(s) endpoint that.
|
Only specify if the service runs an HTTP(s) endpoint that.
|
||||||
If managed, will be passed as JUPYTERHUB_SERVICE_URL env.
|
If managed, will be passed as JUPYTERHUB_SERVICE_URL env.
|
||||||
"""
|
"""
|
||||||
).tag(input=True)
|
).tag(input=True)
|
||||||
api_token = Unicode(
|
api_token = Unicode(
|
||||||
help="""The API token to use for the service.
|
help="""The API token to use for the service.
|
||||||
|
|
||||||
If unspecified, an API token will be generated for managed services.
|
If unspecified, an API token will be generated for managed services.
|
||||||
"""
|
"""
|
||||||
).tag(input=True)
|
).tag(input=True)
|
||||||
|
Reference in New Issue
Block a user