fix named_servers, change server.base_url

This commit is contained in:
Christian Barra
2017-04-15 03:47:09 +03:00
parent 4c79a8cb2d
commit 76b589bc90
4 changed files with 14 additions and 13 deletions

View File

@@ -220,11 +220,11 @@ class UserCreateNamedServerAPIHandler(APIHandler):
user = self.find_user(name)
if user is None:
raise HTTPError(404, "No such user %r" % name)
if user.running:
# include notify, so that a server that died is noticed immediately
state = yield user.spawner.poll_and_notify()
if state is None:
raise web.HTTPError(400, "%s's server is already running" % name)
#if user.running:
# # include notify, so that a server that died is noticed immediately
# state = yield user.spawner.poll_and_notify()
# if state is None:
# raise web.HTTPError(400, "%s's server is already running" % name)
options = self.get_json_body()
yield self.spawn_single_user(user, options=options)
@@ -246,8 +246,8 @@ class UserDeleteNamedServerAPIHandler(APIHandler):
if user.stop_pending:
self.set_status(202)
return
if not user.running:
raise web.HTTPError(400, "%s's server is not running" % name)
#if not user.running:
# raise web.HTTPError(400, "%s's server is not running" % name)
# include notify, so that a server that died is noticed immediately
status = yield user.spawner.poll_and_notify()
if status is not None:

View File

@@ -503,8 +503,8 @@ class JupyterHub(Application):
def _authenticator_default(self):
return self.authenticator_class(parent=self, db=self.db)
allow_multiple_servers = Bool(False,
help="Allow multiple single-server per user"
allow_named_servers = Bool(False,
help="Allow named single-user servers per user"
).tag(config=True)
# class for spawning single-user servers
@@ -1343,7 +1343,7 @@ class JupyterHub(Application):
subdomain_host=self.subdomain_host,
domain=self.domain,
statsd=self.statsd,
allow_multiple_servers=self.allow_multiple_servers,
allow_named_servers=self.allow_named_servers,
oauth_provider=self.oauth_provider,
)
# allow configured settings to have priority

View File

@@ -470,7 +470,7 @@ class Spawner(LoggingConfigurable):
"""
d = {'username': self.user.name}
if self.user.server:
d['base_url'] = self.user.server.base_url
d['base_url'] = self.server_base_url
return d
def format_string(self, s):
@@ -495,7 +495,7 @@ class Spawner(LoggingConfigurable):
"""
args = [
'--user="%s"' % self.user.name,
'--base-url="%s"' % self.user.server.base_url,
'--base-url="%s"' % self.server_base_url,
'--hub-host="%s"' % self.hub.host,
'--hub-prefix="%s"' % self.hub.server.base_url,
'--hub-api-url="%s"' % self.hub.api_url,

View File

@@ -236,7 +236,8 @@ class User(HasTraits):
db.commit()
spawner = self.spawner
# Passing server_name to the spawner
# Passing server_name and base_url to the spawner
spawner.server_base_url = base_url
spawner.server_name = server_name
spawner.user_options = options or {}
# we are starting a new server, make sure it doesn't restore state